Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: plotting legend hangs and cannot read from text file #826

Closed
adigitoleo opened this issue Feb 6, 2022 · 9 comments
Closed

Comments

@adigitoleo
Copy link

I had some code that worked before ca. version 0.38?

    legend(
        legendfile,
        position = (; anchor = :BL),
        box = (; pen = :thinner, fill = :white),
    )

This now complains that option -D is not set, which is aliased to position. I tried adding inside = :BL to the position NamedTuple, but then the code hangs indefinitely.

I'll try to come up with a proper minimal reproducible example.

@adigitoleo
Copy link
Author

Reproduced on v0.40.1 with:

julia> using GMT

julia> gmtbegin("test_legend.png")

julia> coast(region = (110, 210, -35, 45), projection = :Mercator, frame = :auto, land = :dimgray, shore = :thinner)

julia> arrows(hcat(rand(110:210, 10), rand(-35:45, 10), zeros(10), rand(-90:90, 10), rand(1:3, 10)), linewidth = :thickest, linecolor = :black, vecmap = (; justify = :center), transparency = 33)

julia> open("legend.txt", append = true) do file
           println(file, "S 0.25c - 0.33 black 2p 0.75c 1s delay time")
       end

julia> legend("legend.txt", position = (; inside = :BL, anchor = :BL), box = (; pen = :thinner, fill = :white))
^Z
zsh: suspended  julia --banner=no --project=$PWD
admin@hades ~/Documents/PhD/code/Maps
%zsh> cat legend.txt                                                                              [bg:1]
S 0.25c - 0.33 black 2p 0.75c 1s delay time
admin@hades ~/Documents/PhD/code/Maps
%zsh> fg                                                                                          [bg:1]
[1]  + continued  julia --banner=no --project=$PWD


julia> gmtend(show = true)

Produced a box with no contents, and legend call had to be interrupted with Ctrl-D.

image

@joa-quim
Copy link
Member

joa-quim commented Feb 7, 2022

... did a lot of improvements in legend some versions ago.
Seems that not all were improvements.

@adigitoleo

This comment was marked as off-topic.

@adigitoleo

This comment was marked as off-topic.

@adigitoleo
Copy link
Author

Seems to be two issues: the missing width segfault and inability to read from a legend file:

julia> gmtbegin("test_legend.png")

shell> cat legend.txt
S 0.25c - 0.33 black 2p 0.75c 1s delay time
S 0.25c - 0.33 black 2p 0.75c 1s delay time

julia> legend("legend.txt", position = (; inside = :BL, anchor = :BL, width = 5), box = (; pen = 0.5), region = (0, 10, 0, 8))
legend [WARNING]: File <stdin> is empty!

julia> gmtend(show = true) # No legend

@adigitoleo
Copy link
Author

The file reading issue persists in old GMT mode:

julia> using GMT

shell> cat legend.txt
S 0.25c - 0.33 black 2p 0.75c 1s delay time
S 0.25c - 0.33 black 2p 0.75c 1s delay time

julia> legend("legend.txt", position = (; inside = :BL, anchor = :BL, width = 5), box = (; pen = 0.5), region = (0, 10, 0, 8))
pslegend [WARNING]: File <stdin> is empty!

julia> showfig()

@adigitoleo adigitoleo changed the title Regression: plotting legend is hanging indefintely Regression: plotting legend hangs and cannot read from text file Feb 7, 2022
@joa-quim
Copy link
Member

joa-quim commented Feb 7, 2022

Yep, I can see that in pslegend.jl the cmd0 arg that contains the file name is only used in monolithic mode.
This one should be easy to fix.

@joa-quim
Copy link
Member

joa-quim commented Feb 7, 2022

Fixed in #829

@adigitoleo
Copy link
Author

Thanks, it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants