Time axis, issues with setting tick positions, tick label formatting and placement.

Ouverte
#8,937 12 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
45/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Calme
Stack technique
c

Piste de recherche

Commencez par reproduire le problème avec les quatre commandes GMT basemap et comparez leurs positions de graduations, leurs formats d’étiquettes et leur alignement avec l’exemple gnuplot. Consultez la gestion par GMT des axes temporels avec -Bxa/-Bxf et FORMAT_DATE_MAP/FORMAT_TIME_PRIMARY_MAP. C’est terminé lorsque les positions demandées à 14 jours, les étiquettes de type "%b %d" et le placement centré se comportent de manière cohérente, sans étiquettes supplémentaires ou mal placées.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

bug discussion

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

Plot:
Image

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
Image

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
Image

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
Image

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
Image

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.

Langage dominant
C
Étoiles
997
Forks
420
Merge moyen
13 h 27 min
PR mergées (30 j)
47

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de GenericMappingTools/gmt

Toutes les issues de GenericMappingTools/gmt

Issues similaires

Plus d'issues C

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.