# pgfplots: minor y ticks not showing

below code does does not draw y minor ticks. I could specify them manually, but would prefer to have them drawn automatically by 'minor y tick num=1'. Also I do not understand why exactly they are not drawn in the example. Can anybody help?

\documentclass{standalone}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
grid=major,
minor x tick num=1,
minor y tick num=1,
xtick={0,10,...,40},
ytick={0,0.2,...,1},
%   minor ytick={0.1,0.3,...,0.9},
xmin=0,
xmax=40,
ymin=0,
ymax=1,
]
\end{axis}
\end{tikzpicture}
\end{document}
• Are you joking? – ferahfeza Mar 19 '16 at 18:04
• I don't understand what you want to get. – juanuni Mar 19 '16 at 18:06
• I would like to get minor y ticks at 0.1,0.3,0.5,0.7 and 0.9 without specifying manually – Milton Mar 19 '16 at 18:37
• And if you try with minor y tick num=0.1? – juanuni Mar 19 '16 at 19:08

Just providing the minor x tick num=1 already gives the desired result. But I have given more possibilities in the code below how you can set minor yticks. Have a look there.

% used PGFPlots v1.13
\documentclass[border=2mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=0,
xmax=40,
ymin=0,
ymax=1,
grid=major,
xtick={0,10,...,40},
minor x tick num=1,
% only setting the following key gives the desired result already
minor y tick num=1,
% ---------------------------------------------------------------------
%        % I think giving the ytick's as abbreviated list causes some
%        % rounding problems and that is why the minor ytick's are not drawn
%        % ...
%        ytick={0,0.2,...,1.0},
%        % ... this is supported by the fact when giving each entry also the
%        % ytick's are drawn correctly
%        ytick={0,0.2,0.4,0.6,0.8,1.0},
%        % a simpler method to provide an equidistant tick position is using
%        % the following key which then also works fine with the
%        % minor y tick num' key
%        ytick distance={0.2},
%        % and as you already have found out, this should be the last option
%        % to take into consideration
%        minor ytick={0.1,0.3,...,0.9},
]
\end{axis}
\end{tikzpicture}
\end{document}

• Dear Stefan, thank you very much for the detailed answer. I will use x/y tick distance from now on. Totally missed it in the manual. Info on rounding errors – Milton Mar 19 '16 at 19:19
• @user3795444, you are welcome. Besides accepting the answer you can also upvote it, if you are satisfied with my answer. – Stefan Pinnow Mar 19 '16 at 19:37
• @user3795444, at the rounding error: Great, that you have found an example proving it. I was just to lazy to search for it ;) – Stefan Pinnow Mar 19 '16 at 19:38