GMT.jl
GMT.jl copied to clipboard
Specifying a colourmap on ternary plots with image=true adds a large grey square
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
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)
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
Hmm, can't reproduce the gray box issue.
These are created in my local machine (Windows) and copied to (SSL certificate expired site) http://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.
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:
Details: GMT version: 0.42.4 OS: Ubuntu 20.04
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
Thank you so much! That works perfectly!
If you update to master you won't need to change the C.bfn
anymore