-
Notifications
You must be signed in to change notification settings - Fork 407
Description
I wanted to set X axis as time, set major ticks every 2 weeks (14 days), and format tick labels as "%b %d", aligned (centered) exactly at the axis tick positions. My example data range is a bit shorter than 2 months.
In short: I want to have time tick placement, labels format specs and label alignment as shown in my gnuplot example. I am not getting this with GMT. See more below.
My gnuplot code and figure is presented to demonstrate what I want and how it is specified. Further down I posted what I was able to get using GMT, the code and the results that I don't like at all - mostly erratic tick positions, misaligned tick labels, and label formats not respecting the requested specifications.
I want to get the same result I get with gnuplot. Gnuplot apparently (naively) counts 2-week intervals starting from the epoch. This way major ticks appear at 2019-02-21 etc. These major tick positions are a whole number of 2-week periods away from the epoch of 1970-01-01. I want to get the same tick positions and tick labels aligned the same way in GMT.
NB a standard way of specifying tick label format using C strftime format specifiers. A significant advantage for the user (me) that tick label of types Time and Date become essentially the same with this approach. Time/Date formatting seems two different things with GMT. It is not clear why it is so and what benefits it brings. The documentation and examples are scarce and scattered across several different places.
NB 1 Gnuplot's approach to the time interval/tick placement implies that regardless of the specified time interval all the time ticks and labels always remain at exactly the same positions.
My gnuplot code:
set term pngcairo enhanced size 800,80 font "Helvetica,14"
set output "gnuplot.png"
set xdata time
set timefmt "%Y-%m-%d"
set xrange ["2019-02-15" to "2019-04-08"]
set yrange [0 to 1]
unset ytics
set xtics 3600*24*14 nomirror out
set format x "%b %d"
set border 1
plot 0/0 notitle
Now to my GMT trials and the results.
When I specify -Bxa14Rf7R the following --FORMAT_DATE_MAP="o dd" is not respected, label format is just the date of month, labels are misaligned and printed a bit away from the ticks:
gmt basemap -R2019-02-15T/2019-04-08T/-20/+20 -JX10c -BS -Bxa14Rf7R -png R --FORMAT_DATE_MAP="o dd" --FORMAT_TIME_PRIMARY_MAP=abbrev
When I specify -Bxa2Uf1U --FORMAT_DATE_MAP="o dd" --FORMAT_TIME_PRIMARY_MAP=abbrev label format is correct but the labels are misaligned and printed far away from the ticks:
gmt basemap -R2019-02-15T/2019-04-08T/-20/+20 -JX10c -BS -Bxa2Uf1U -png U --FORMAT_DATE_MAP="o dd" --FORMAT_TIME_PRIMARY_MAP=abbrev
When I specify -Bxa14Df7D --FORMAT_DATE_MAP="o dd" --FORMAT_TIME_PRIMARY_MAP=abbrev I get extra label at Apr 01 right on top of Mar 29, plus the labels are misaligned, that is, not centered exactly at the tick positions:
gmt basemap -R2019-02-15T/2019-04-08T/-20/+20 -JX10c -BS -Bxa14Df7D -png D --FORMAT_DATE_MAP="o dd" --FORMAT_TIME_PRIMARY_MAP=abbrev
With -Bxa14Df7D --FORMAT_DATE_MAP="o dd" --FORMAT_TIME_PRIMARY_MAP=abbrev i get essentially the same labels as before: only date is printed, aligned away from the tick positions. The requested abbreviated month name is just disregarded:
gmt basemap -R2019-02-15T/2019-04-08T/-20/+20 -JX10c -BS -Bxa14df7d -png d --FORMAT_DATE_MAP="o dd" --FORMAT_TIME_PRIMARY_MAP=abbrev
I want in principle to have time tick placement labels and formatting as in gnuplot. This implies tick labels centered exactly at the tick positions by default (interval labels centered at the center of the interval), standard label format specifiers and standard tick position evaluation as in gnuplot, that is, all tick positions relative to the epoch.
Congrats and thanks to all those who managed to read that far down.
