Reputation: 1892
Is there any possibility in gnuplot to format time-based tic labels with custom functions? I know that I can use the regular format codes like
set format x '%Y-%m-%d, %a'
In this example the %a
would print English short names of the weekday. So I wrote a mapping function that could translate the name to German:
dow(d) = \
(d == 0) ? 'So' : \
(d == 1) ? 'Mo' : \
(d == 2) ? 'Di' : \
(d == 3) ? 'Mi' : \
(d == 4) ? 'Do' : \
(d == 5) ? 'Fr' : \
'Sa'
But how can I call this function? The correct format string would be %w
, but this:
set format x '%Y-%m-%d, ' . dow('%w')
does not work, because it tries to actually pass the string "%w" to my function. I also know that there's tm_wday(t)
(where the argument t
would be an Unix timestamp) which returns the 0-based number of the weekday (which my mapping function needs). But how would I tell set format x
to take the current tic value (which actually is internally an Unix timestamp when setting set xdata time
) as an argument to this function?
I'm using the latest gnuplot trunk version, if this is of any relevance (so I can use any feature that currently exists, even if still undocumented).
Upvotes: 1
Views: 337
Reputation: 48390
The locale
settings determine how numbers and dates in tic labels are formatted, e.g.
set locale 'de_DE.utf8'
or
set locale 'German_Germany.1252'
depending on your system.
Upvotes: 2