I am using pgfplots to plot the following diagram with monthtly data over 20 years. However, I am not quite satisfied with the labels on the x axis. I'd like to have steps of say 3 years (e.g. 1994, 1997, 2000, 2003, 2006, 2009, 2012). Right now there are steps of 2 years and 3 years. Can anyone help?

enter image description here



    width=13cm, height=9cm,  
    date coordinates in=x,  
    xticklabel style={/pgf/number format/1000 sep=},  
    date ZERO=1993-01-01,  
        tick pos=left,   
        legend pos=outer north east,   
    legend cell align=left,   

\addplot table[x=year,y=greece] {data.csv};\addlegendentry{Greece}   
    \addplot table[x=year,y=portugal] {data.csv};\addlegendentry{Portugal}   
    \addplot table[x=year,y=ireland] {data.csv};\addlegendentry{Ireland}   
    \addplot table[x=year,y=italy] {data.csv};\addlegendentry{Italy}   
    \addplot table[x=year,y=spain] {data.csv};\addlegendentry{Spain}   
    \addplot table[x=year,y=belgium] {data.csv};\addlegendentry{Belgium}   
    \addplot table[x=year,y=austria] {data.csv};\addlegendentry{Austria}   
        \addplot table[x=year,y=france] {data.csv};\addlegendentry{France}   
        \addplot table[x=year,y=netherlands] {data.csv};\addlegendentry{Netherlands}   
        \addplot table[x=year,y=germany] {data.csv};\addlegendentry{Germany}   



You can use dates in xtick to specify where you want xticks, e.g.

xtick = {

Add this to the axis options.

  • That's exactly what I was looking for. Thank you so much! I was trying xtick before but obviously in the wrong format.
    – pukas
    Jan 4 '14 at 20:27
  • 1
    @pukas Glad I could help. Perhaps you would consider accepting my answer by clicking the checkmark on the left, that marks the question as resolved, and awards some points to both yourself and me. Jan 5 '14 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.