我有一个半对数图的例子,其中 x 轴为对数模式,范围从到xmin=1
。xmax=10^3
当我减少时,xmax=900
小刻度消失。但是,如果我增加,一切仍然正常。这种行为背后的想法是什么?强制对数小刻度的正确方法是什么?当我调用另外的时,xmax=2000
我可以恢复版本中的小刻度- 然而,这对我来说似乎是倒退的。xmax=900
xtick={1e1,1e2,1e3},
\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}
正如评论中提到的,PGFplots 似乎会改变主刻度,xmax=900
但是当图的宽度有限时,主刻度是不可见的。删除该width=6cm
命令会产生: