2

I have the example of a semilogplot, where the x-axis is in log-mode ranging from xmin=1 to xmax=10^3. When I reduce xmax=900 the minor ticks disappear. However if I increase xmax=2000 everything is still ok. What is the idea behind this behavior and what is the proper way to enforce log minor ticks? I can restore the minor ticks in the xmax=900 version, when I invoke xtick={1e1,1e2,1e3}, additionally - this however seems backwards to me.

\RequirePackage{luatex85}
\documentclass[]{standalone}
\usepackage[]{amsmath,amssymb}
\usepackage{tikz}
\usepackage[]{pgfplots}
\usepgfplotslibrary{ units,colorbrewer}
\pgfplotsset{compat=newest, cycle list/Dark2-7,}

\begin{document}
\begin{tikzpicture}

\begin{axis}[/tikz/ybar interval, 
cycle list name=Dark2-7, 
width=6cm,
xmode=log,
    ymin=0,
    ymax=49,
xmin=1e1, xmax=900, 
xticklabel pos=right,
title style={yshift=0.5cm},
title={Minor Ticks broken (xmax=900)}
]
\addplot+[fill, fill opacity=0.8,thick, ] table[skip first n=2, col sep=comma,  x index={0}, y index={1},]{
100, 10
200, 30
300, 50
};
\end{axis}
\end{tikzpicture}


\begin{tikzpicture}
\begin{axis}[/tikz/ybar interval, 
cycle list name=Dark2-7, 
width=6cm,
xmode=log,
    ymin=0,
    ymax=49,
xmin=1e1, xmax=1000, 
xticklabel pos=right,
title style={yshift=0.5cm},
title={Minor Ticks OK (xmax=1000)}
]
\addplot+[fill, fill opacity=0.8,thick, ] table[skip first n=2, col sep=comma,  x index={0}, y index={1},]{
100, 10
200, 30
300, 50
};
\end{axis}
\end{tikzpicture}


\begin{tikzpicture}
\begin{axis}[/tikz/ybar interval, 
cycle list name=Dark2-7, 
width=6cm,
xmode=log,
    ymin=0,
    ymax=49,
xmin=1e1, xmax=2000, 
xticklabel pos=right,
title style={yshift=0.5cm},
title={Minor Ticks OK (xmax=2000)}
]
\addplot+[fill, fill opacity=0.8,thick, ] table[skip first n=2, col sep=comma,  x index={0}, y index={1},]{
100, 10
200, 30
300, 50
};
\end{axis}
\end{tikzpicture}


\begin{tikzpicture}
\begin{axis}[/tikz/ybar interval, 
cycle list name=Dark2-7, 
width=6cm,
xmode=log,
    ymin=0,
    ymax=49,
xmin=1e1, xmax=900, 
xticklabel pos=right,
xtick={1e1,1e2,1e3},
title style={yshift=0.5cm,align=center},
title={Minor Ticks OK (xmax=900),\\ manually enforced}
]
\addplot+[fill, fill opacity=0.8,thick, ] table[skip first n=2, col sep=comma,  x index={0}, y index={1},]{
100, 10
200, 30
300, 50
};
\end{axis}
\end{tikzpicture}

\end{document}

MWE compliation

As mentioned in the comments, PGFplots seems to change the major ticks, when xmax=900 which, however, is not visible when the width of the plot is limited. Removing the width=6cm command produces: First and last plot without <code>width=6cm</code>

Matthias Arras
  • 966
  • 6
  • 19
  • I just saw, while making the MWE more MWE like, that removing the width=6cm argument gives more insight into the origin of the behavior. pdfplots introduces major ticks at 10^1.5 and 10^2.5 when the plot is big enough to allow for it, which may not allow to keep the minor log ticks. – Matthias Arras May 08 '18 at 19:38

0 Answers0