我有一个简单的图表,其中的辅助 Y 轴上的数字非常小。以下是生成该图表的代码:
\begin{tikzpicture}
\begin{axis}[
xtick=data,
axis y line*=left,
axis x line=bottom,
xlabel=\textbf{m},
ylabel=\textbf{p\textsubscript{m}},
ymajorgrids=true,
xmin=0, xmax=100,
ymin=0, ymax=0.3
]
\addplot[ybar,fill=blue] coordinates {
(10, 0.21)
(30, 0.22)
(50, 0.24)
(70, 0.19)
(90, 0.1)
};
\end{axis}
\begin{axis}[
axis y line*=right,
axis x line=none,
axis line style={-},
ymin=0, ymax=0.0122
]
\addplot [ultra thick, orange, stack plots=false,line join=round,smooth] coordinates {
(10, 0.0067)
(30, 0.011)
(50, 0.012)
(70, 0.0093)
(90, 0.0049)
};
\end{axis}
\end{tikzpicture}
问题是*10^-2
图表右侧 Y 轴的标签卡在左侧,我不知道该怎么办。有办法解决这个问题吗?
还有错误的图片:
答案1
正如我在在问题下方评论,只需将compat
级别 1.3 或更高级别添加到文档前言中即可获得所需结果。
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{
compat=1.3,
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xtick=data,
axis y line*=left,
axis x line=bottom,
xlabel=\textbf{m},
ylabel=\textbf{p\textsubscript{m}},
ymajorgrids=true,
xmin=0, xmax=100,
ymin=0, ymax=0.3
]
\addplot[ybar,fill=blue] coordinates {
(10, 0.21)
(30, 0.22)
(50, 0.24)
(70, 0.19)
(90, 0.1)
};
\end{axis}
\begin{axis}[
axis y line*=right,
axis x line=none,
axis line style={-},
ymin=0, ymax=0.0122
]
\addplot [ultra thick, orange, stack plots=false,line join=round,smooth] coordinates {
(10, 0.0067)
(30, 0.011)
(50, 0.012)
(70, 0.0093)
(90, 0.0049)
};
\end{axis}
\end{tikzpicture}
\end{document}