How does colorbar -Zzfile
option work?
I’ve been wresting with log-scale color scales needed to replicate a colleague’s color scale from Matlab (rotated to fit here):
I thought I could do it with the -Zzfile
option of colorbar, but I couldn’t get it to work. I couldn’t find any examples of the -Z
option in the docs or test files (using github’s search…). I calculate widths.txt
from the cpt file.
- seis_pgv.cpt.txt (462 Bytes) - created by hand using a color picker for RGBs at annotated values on target colorbar
- widths.txt (92 Bytes)
awk '{print (log($3)-log($1))/log(10)}' seis_pgv.cpt.txt > widths.txt
gmt begin sample_colorbar_Z png
gmt colorbar -Cseis_pgv.cpt -DJCB+h -R0/1/0/1 -Zwidths.txt
gmt end show
This script hangs after throwing the first psconvert error, and then after killing the process, dumps the rest. When I ran this command for as a sub-plot (so the -R
option was set in subplot begin
), it created an empty sub-plot and didn’t seem to throw this error (so this psconvert error is a side effect of colorbar -Zzfile
not plotting anything?).
psconvert [ERROR]: Unable to decode BoundingBox file /Users/ja/.gmt/sessions/gmt_session.2243/psconvert_2249c.bb (maybe no non-white features were plotted?)
psconvert [ERROR]: System call [gs -q -dNOPAUSE -dBATCH -dNOSAFER -dSCANCONVERTERTYPE=2 -dMaxBitmap=2147483647 -dUseFastColor=true -dGraphicsAlphaBits=2 -dTextAlphaBits=4 -sDEVICE=png16m -g136530x136530 -r300 -sOutputFile='sample_colorbar.png' '/Users/ja/.gmt/sessions/gmt_session.2243/psconvert_2249d.eps'] returned error 2.
end [ERROR]: Failed to call psconvert
end [ERROR]: gmtinit_process_figures returned error 79
GMT v6.2.0 via homebrew on macOS 10.14.6
Alternative solution - Custom Axes
I found one solution using -Bpxc
for Custom Axes (not mentioned in colorbar
docs or -B
reference docs?), but it felt like there may be a simpler option and I can’t seem to get the lines (grid) across the colorbar. On the upside, it looks like I can use one large annotations file (e.g. from 0.001 to 1000 and use it for different data ranges, 0.01 to 10, 1 to 200, etc.).
- annots.txt (117 Bytes) - created by hand (could also be derived from CPT)
gmt begin sample_colorbar png
# does colorbar work in one-line mode?
gmt colorbar -Cseis_pgv.cpt.txt -DJCM+h -R0/1/0/1 -Q -Bpxc"annots_sa.txt"
gmt end show
Creates:
Thank you,
Jason