I would like to plot temporal data and have dates as tick labels. I have seen chapter 4.20 Symbolic Coordinates and User Transformations from pgfplots manual but it does not correspond to my situation because my dates are already formated as numbers. There is a remark to that effect
Remark: This section applies to users who want to have non-standard input coordinates. If you have normal numbers which don't need to be transformed and you like to have special symbols as tick labels, you should consider using the xticklabels (yticklabels) key described on page 224.
So I have read page 224 and following but I could not figure it out.
I reckon something could be done with the pgfplotstable and
pgfcalendar packages but once again I fail to find the relevant
information.
I ended up using a manual solution which require adjustment whenever
the data change and even needed a scaled ticks=false to prevent some
overlapping in some specific cases.
How could I have done this cleanly ?
Here is an exemple derived from my current code :
\documentclass{article}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\begin{document}
\begin{tikzpicture}
\pgfplotstableread{
7.3124563e+005 4
7.3139367e+005 3
7.3165463e+005 2
7.3233467e+005 1
7.3262672e+005 6
7.3279571e+005 5
7.3320909e+005 4
7.3338963e+005 3
7.3385267e+005 2
7.3465509e+005 6
}\mytable
\begin{axis}[%
xtick={730852, 731582, 732313, 733043, 733774, 734504},%ugliness here
xticklabels={2001, 2003, 2005, 2007, 2009, 2011},%and there
xlabel={Date},
ylabel={Data},
scale only axis,
width=8cm,
height=5cm,
axis on top,
scaled ticks=false]%and here again!
\addplot table[x index=0,y index=1]{\mytable};
\end{axis}
\end{tikzpicture}
\end{document}
The time format I use comes from MATLAB
datenumanddatestrfunction which is similar to what is used by thepgfcalendarpackage except that a shift in range is needed. Namely, one unit is one day, fractional part gives the time. 1-Jan-0000 is coded by 0.0 and 7.3188e+005 correspond to 24-Oct-2003 12:45:07.
x filter/.code, but in my humble opinion, you can just use excel or matlab to convert them automatically since it won't be worth it to do a full rigorous conversion. Is there any limitation on your side that prevents this? – percusse May 26 '12 at 9:24x filterstuff of pgfplots). Let us know if you decide to stick with the filter-solution. – Christian Feuersänger May 27 '12 at 7:38