Setting the font for the time stamp

Hi,

I’m sure I’m doing something silly. I am putting time stamps (-U) on my plots, and want to change the colour from black to something else. So I do this:

gmt gmtset FONT_LOGO auto,Helvetica,blue (or whatever colour I’m interested in)

But no matter what, -U seems to ignore the FONT_LOGO setting and uses 8pt,Helvetica,black

I’m in modern mode.

Here’s my plot and code - You can see I want the timestamp to be the same colour as the chart (${chartcol})

gmt begin barograph pdf,png A+m0.5c
    	gmt gmtset FONT_LOGO auto,Helvetica,${chartcol}
    	gmt plot chart.txt -JX${plen}/$((${phgt}+2)) ${chartreg} -N \
    		-U"Plotted by Tim Hume"+jTL+o2.5/-0.2
    	gmt text labels.txt -F+f+a+j -N -DJ0/0.2 -Gwhite
    	gmt text -F+f+a+j -N <<- END
    	0 $((${phgt}/2+1.5)) 12p,Helvetica-Oblique,${chartcol} 0 LM STATION: ${stn}
    	END
    	barocoords ${plen} ${phgt} ${pmin} ${pmax} ${tmin} ${tmax} \
    		${arm} < data.txt | gmt plot -Wthin,${pencol}
    gmt end

And for anyone interested, see the pressure wave when the Tongan volcano erupted.

1 Like

Nice. Is this guy who creates the data to do the green plot?

Yeah. We’ve got cartesian coordinates: (t, P) (t=time, P=pressure) and we need to transform these onto the barograph charts coordinate system where the time grid lines are curved. The reason for this is that the barograph has a stylus on the end of an arm which will traces out the pressure on a rotating drum.

Actually, all the seismologists here will be familiar with the concept!

Most meteorological data nowadays are digital, so people just plot time series on Cartesian maps. But there are still a few analogue instruments being maintained by volunteers. And people like the look of the old instruments and charts.

The code snippet I sent was just the plotting part of a longer ksh script. The coordinates of the green lines are computed and transformed into the chart coordinates, and saved in the files called chart.txt and labels.txt

1 Like

Yep, I know them from either meteorological instruments as well as seismographs. Very cool plots and refreshing in these times of xy plots all so similar.

It would be fun to make GMT.jl plotting function that creates them (but time is so short).

The coordinate transformation is simple. I use awk (why use these new-fandangled languages when something from the 70s will do?):

function barocoords {
        #
        # Convert date in format t,p,... to x,y,... on the barograph chart.
        #
        # Input data are provided on stdin and transformed data written to stdout.
        #
        # Arguments
        #
        # $1: length of chart (cm)                                                                      Default: 63
        # $2: height of chart (cm)                                                                      Default: 15
        # $3: mimimum pressure (hPa)                                                            Default: 950
        # $4: maximum pressure (hPa)                                                            Default: 1050
        # $5: minimum time (s since 1970-01-01T00:00:00)        Default: 7 days ago
        # $6: maximum time (s since 1970-01-01T00:00:00)        Default: Now
        # $7: length of barograph arm (cm)                                              Default: 25

        awk -v plen="${1:-63}" -v phgt="${2:-15}" -v pmin="${3:-950}" \
                -v pmax="${4:-1050}" -v tmin="${5:-$(($(gdate -u +%s)-604800))}" \
                -v tmax="${6:-$(gdate -u +%s)}" -v arm="${7:-25}" '
        {
                t = $1;
                p = $2;
                pmid = (pmin + pmax)/2;
                y = phgt*(p - pmid)/(pmax - pmin);
                d = arm - sqrt(4*arm^2 - 4*y^2)/2;
                x = plen*(t - tmin)/(tmax - tmin) + d;
                printf("%f\t%f\t", x, y);
                for (ii=3; ii<=NF; ii++) printf("%s\t", $ii);
                printf("\n");
        }'
}

Sure, awk is a king for all of us, but Julia simplicity (when it’s not complicated) is also a breeze. If you could attach the zip with chart.txt & data.txt I could give it a try.

chart.txt and labels.txt are generated on the fly. I guess if one doesn’t change the chart size etc they could be static files. data.txt is simply a time series with two columns: time in the first column and pressure in the second.

I’ve attached the complete script which does the plotting. Doing a seismograph chart would be a bit more complex. A barograph chart just covers one circuit of the drum, and then the paper is changed. An old style seismograph does many circuits.plot_baro.zip (2.6 KB)

Thanks. I’ll post an example when I have something. And yes, I was thinking in inventing a seismograph too.

1 Like

But returning to my original issue. How do I get the -U timestamp to be in my preferred colour? I’m sure I’ve made a simple mistake.

I don’t see any mistake. Maybe a GMT issue. Can you try a classic version of that script and try also

gmt plot chart.txt -JX${plen}/$((${phgt}+2)) ${chartreg} -N \
    -U"Plotted by Tim Hume"+jTL+o2.5/-0.2 --FONT_LOGO=auto,Helvetica,${chartcol}

It looks like a GMT bug. It doesn’t care about the font size either

julia> plot(rand(4,2), marker=:circ, mc=:red, U="BlaBla", par=(FONT_LOGO="32p,Helvetica,red",), show=1, Vd=1)
        psxy  -JX14c/9.5c -Baf -BWSen --FONT_LOGO=32p,Helvetica,red -R0.12/0.8/0.06/0.9 -Sc7p -Gred -UBlaBla -P -K > C:\TEMP\GMTjl_tmp.ps

Here are the things I see that you can affect regarding the timestamp:

  1. You can change the font used but not its size or color via FONT_LOGO
  2. You can change the white color of the box via PAGE_RGB but that changes the entire page color
  3. You can change the specific formatting of the time stamp via FORMAT_TIME_STAMP
  4. You can change the default placement of the time stamp via MAP_LOGO_POS
  5. You can change the color of the box beneath the GMT glyph via MAP_DEFAULT_PEN but that is entirely overprinted by the black/white glyph anyway

Basically, we never intended for users to change attributes related to the time stamp. For instance, the width is carefully set to match what is needed for that font size (and explicitly for Helvetica), it is not computed to fit whatever text ends up being set.

1 Like

Thanks. I’ll just add any additional stuff like time stamps using gmt text. I kind of like the -U because it also puts in a subtle advertisement for GMT :slight_smile:

1 Like

Apropos; it look’s like the font for the stamp isn’t changed even when using GMT_THEME=minimal . Shouldn’t it be set to AvantGarde-Book?

gmt psbasemap -R0/10/0/10 -JX6c -pdf test -Bafg -B+t"Plot" -U --GMT_THEME=minimal

My thought when setting up the minimal theme was that the GMT logo/timestamp is a bit like a brand and I didn’t want to mess with it by using a different font for FONT_LOGO even in the new theme.

Exactly. If anything, I would like to remove FONT_LOGO since this is not something we wish to offer and maintain.

Why? What is the issue with letting FONT_LOGO actually set a fontsize,fontname,fontcolor font?

Setting a font size would mean overprinting the box, etc. Its size is not determined from the size of the text (well ,it is hard wired based on the default size of the text and not meant to be changed.

I’ve re-done the time stamp using “gmt logo” and “gmt text”. Quite nice (in my opinion, and an even better advert for GMT :slight_smile:)