Different annotation colors

Added by Yacob 2 months ago

Dear All,

Is it possible to have different annotation colors for a given axis range. Say if I have my X- axis range
varies from 1990 to 2017 . I would only like to change the annotation color only from 2000 to 2017 but
use a different color for the range from 1990 to 1999. I know how to change the color for the whole
axis annotation range but not part of the annotation.

The same goes for the y-axis (e.g -R1990/2017/10/20)

I use GMT version 6.0.0_r18765

Kind regards,


Replies (3)

RE: Different annotation colors - Added by Paul 2 months ago

No, there is no mechanism to change the color of the annotation font other than a constant color. You would have to mess around with pstext for such an effect, or post-process the PS somehow.

RE: Different annotation colors - Added by Walter 2 months ago

I agree with Paul that there is no mechanism to do this directly.
However I think there is an easier way than using pstext or post-processing the PostScript. If you have a tool that will open the PostScript and let you select text blocks with the mouse and change their color easily, and if you only need to do this once in awhile, then use that. But if you want to do it often you could do something like this with GMT:

plot you data and if you want a label in the center of the (total, combined) X axis, and want it in the current FRAME_COLOR (say, black), then use -B:"X Axis Label":[/y_axis_stuff]
Then if the total length of your X axis is X_total (which you might have if your map projection was, for example, -JX<X_total>, you can compute
X_1 = X_total * (1999.5 - 1990.0)/(2017.0 - 1990.0);
X_2 = X_total - X_1;
Then make two calls to psbasemap to do your X axis annotations in two different colors, e.g.
gmtset BASEMAP_FRAME_RGB red (or whatever color)
psbasemap -R1990/1999.5/10/20 -JX<X_1> -Ba2f1:SN -O -K >> yourplot.ps
gmtset BASEMAP_FRAME_RGB blue (or whatever color)
psbasemap -X<X_1> -R1999.5/2017/10/20 -JX<X_2> -Ba2f1:SN -O >> yourplot.ps

Sorry, this is GMT-4 syntax and you are using GMT-6 (Good for you!). I don't have a GMT-6 platform handy to test this idea at the moment.

What I am suggesting is that you use two calls to psbasemap to plot the X axis and its labels twice, in two different colors, each call has to use the range of X you want, at the right scale (-J) and position (-X) so that the appropriate lengths and offsets get drawn.

I hope this is helpful.

RE: Different annotation colors - Added by Yacob 2 months ago

Dears Paul and Walter,

Thank you for your suggestions. I am trying what Walter has suggested. Once again let me take the opportunity to say thank you for the dedication to make this GMT package an awesome tool one could wish for.

Kind regards