我读过这个链接pgfplot 两侧 y 轴的标签我想检查是否可以在两边都有 xtick 和 ytick,即刻度数字。我使用的 MWE 与pgfplot 两侧 y 轴的标签。
\documentclass{beamer}
\usepackage{pgfplots}
\begin{document}
\pgfplotsset{
ylabel right/.style={
after end axis/.append code={
\node [rotate=90, anchor=north] at (rel axis cs:1,0.5) {#1};
}
}
}
\begin{tikzpicture}
\begin{axis}[ylabel=Left label, ylabel right=Right label]
\addplot coordinates {(0,1) (1,1)};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
像这样:
\documentclass{beamer}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ylabel=Left label
]
\addplot coordinates {(0,1) (1,1)};
\end{axis}
\begin{axis}[
ylabel=Right label,
y label style={at={(1.12,0.5)},anchor=north},
yticklabel pos=right
]
\end{axis}
\end{tikzpicture}
\end{document}