2

I wonder why minor ticks are not displayed even though

    minor y tick num=4  

was specify when I use pgfplots.I know there is a way to manually add the minor y tick by

    minor ytick={0.04,0.08,...,1.6}

but I want it added automatically because lots of data like the table listed below are waiting to be processed .Here is my minimal work code

\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc} %
\usepackage{pgfplots}
\usepackage{pgfplotstable}

\begin{document}
\begin{tikzpicture}
\begin{axis}[title=R,
                 width=8cm,height=1.1*\axisdefaultheight,
                 %xmode=log,
                 %ymode=normal,
                 log basis x={10},
                 xmin=0,xmax=2e6,ymin=0,ymax=1.6,
                ytick={0,0.2,...,1.6},
                minor y tick num=1,
                yticklabel style={opacity=1,/pgf/number format/.cd,fixed,fixed zerofill,precision=2},
                grid=both,
                every major x grid/.style={red, opacity=0.8},
                every major y grid/.style={blue, opacity=0.5},
                every minor x grid/.style={red!80, opacity=0.8},
                every minor y grid/.style={blue!80, opacity=0.5},
                ]
            \addplot table[
            x expr={\thisrowno{0}},
            y expr={\thisrowno{1}},
            ]{
100 0.0354781
244.9   0.0363808
570.7   0.0402797
1204    0.0510097
1884.4  0.0616097
2669.7  0.0713232
3598.7  0.0808529
5098.5  0.0938683
5358.6  0.0959249
5632.1  0.0980125
5919.4  0.100159
6221.5  0.102366
6538.9  0.104629
6872.6  0.106945
7223.3  0.109323
7591.8  0.111751
7979.2  0.114237
27688   0.202986
61391   0.300919
111500  0.404596
183400  0.510449
273200  0.604212
406800  0.711876
548300  0.806257
739200  0.915297
2000000 1.36077
};%
\end{axis}
\end{tikzpicture}


\end{document} 

Which produce This is what I get

As you can see,the minor y tick not shown as expected.Any suggestion will be appreciated.Thanks a lot.

  • It seems that this is a precision problem of the ytick calculation. If you change the precision setting of yticklabel style to 5, then you can see that there are rounding problems. So may be the major ticks don't have exactly the same distance. Try ytick distance=.2 instead ytick={0,0.2,...,1.6} – esdd Oct 26 '16 at 07:06
  • Thanks a lot. Set ytick distance=.2 Solve my problem.Great appreciate. – Cong Yang Oct 26 '16 at 14:52

0 Answers0