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

Specifying a colourmap on ternary plots with image=true adds a large grey square #952

Open
lucpaoli opened this issue Jul 19, 2022 · 5 comments

Comments

@lucpaoli
Copy link

Sample code from

https://www.generic-mapping-tools.org/GMT.jl/stable/gallery/ternary/ternary/

# Make use of the knowledge that z ranges berween 0 and 71 (gmtinfo module is a friend)
C = makecpt(T=(0,71));
ternary("@ternary.txt", marker=:p, image=true, clockwise=true,
        frame=(annot=:auto, grid=:a, ticks=:a, alabel="Clay", blabel="Silt", clabel="Sand", suffix=" %"),
        show=true)

This produces a large grey square surrounding the ternary diagram

image

If image=false, then

# Make use of the knowledge that z ranges berween 0 and 71 (gmtinfo module is a friend)
C = makecpt(T=(0,71));
ternary("@ternary.txt", marker=:p, image=false, clockwise=true, cmap=C,
        frame=(annot=:auto, grid=:a, ticks=:a, alabel="Clay", blabel="Silt", clabel="Sand", suffix=" %"),
        show=true)

image

cmap then has to be specified for the colourmap to be applied. Note that inputting the cmap explicitly as cmap=C in the first example still produces said grey square.

If you have any advice on what may fix this, it would be much appreciated. I've tried the bg parameters specified at

https://www.generic-mapping-tools.org/GMT.jl/stable/makecpt/

but these do not seem to have helped.

Many Thanks,
Luc

@joa-quim
Copy link
Member

Hmm, can't reproduce the gray box issue.

These are created in my local machine (Windows) and copied to (SSL certificate expired site)
http:https://fct-gmt.ualg.pt/GMTjl_doc/examples/ternary/

and these are built automatically by GH actions

https://www.generic-mapping-tools.org/GMTjl_doc/examples/ternary/

They both are using GMT.jl master (a Conda craziness broke the automatic registration of new GMT.jl versions) but I don't remember to have changed anything that may explain the gray box. See if you happen to have a gmt.conf file in the directory where you are running the GMT commands. Delete it if you have one.
And, what GMT version do you have? (type GMT.GMTver in the REPL).

The cmap issue is a little more tricky. Don't know if it's a good idea to apply the current cmap to color symbols. The mechanism (not needing to set cmap=... when we have an active one) was thought for images and may cause some surprises is applied to symbols as well.

@lucpaoli
Copy link
Author

This issue appears to occur without specifying a non-default colourmap (i.e. the first example I provided) when working in Pluto notebooks, possibly because a non-default cmap is being set elsewhere and is persisting.

In a Jupyter notebook I can obtain the grey box by doing (as a minimum working example):

using GMT
C = makecpt(cmap=:rainbow);
ternary("@ternary.txt", image=true, frame=(suffix=" %"), show=true)

producing:
image

Details:
GMT version: 0.42.4
OS: Ubuntu 20.04

@joa-quim
Copy link
Member

OK, can reproduce and found out why. But not sure who's really the culprit. For the time being use this workaround (too late here for a better fix).

C = makecpt(cmap=:rainbow);
C.bfn[3,:] = [1. 1 1];       # Force the NaNs to be painted as white

@lucpaoli
Copy link
Author

Thank you so much! That works perfectly!

@joa-quim
Copy link
Member

If you update to master you won't need to change the C.bfn anymore

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