Consider the following code:
\documentclass[border=2pt]{standalone}
\usepackage{pgfplots}
\newcommand\myxtick[1]{\foreach \x in {2,3,4}{\x,}#1}
\newcommand\otherxtick{2,3,4,5}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
%xtick={\myxtick[5]},
xtick={\otherxtick},
xmax=10,xmin=0,ymax=10,domain=0:10]
\addplot {x};
\end{axis}
\end{tikzpicture}
\end{document}
If I specify the xtick with \otherxtick the code works but if I use \myxtick[5] it gives me errors and it does not compile. I tried also with xtick./expanded={\myxtick[5]}, xtick./expand once={\myxtick[5]} and xtick./expand twice={\myxtick[5]} but with the same result.
I took a look also at these question but with no result:
I ask this question because the notation {1,2,...,20} for the definition of ticks can not always be used. Consider for example a dateplot in which you want ticks every 3 years from 1900 to 1960. If I write {1900-01-01,1903-01-01,...,1960-01-01} it does not works and write all 21 ticks is very boring...
...-01-01instead of just...– percusse Sep 18 '13 at 08:45