我对多轴图的外观有疑问......
目前我有以下内容:
但是我不希望箭头位于右侧 y 轴,但从文档中我读到命令中的 * axis y line
应该可以阻止这种情况发生...但事实并非如此。此外,上轴(第二个 x 轴出现的位置)现在是灰色的,但我希望它是黑色的。希望有人知道正确的命令来解决这个问题。
\documentclass{standalone}
\usepackage{graphics,siunitx}
\usepackage{tikz,pgfplots}
\begin{document}
\begin{tikzpicture}
\pgfplotsset{%
compat=1.6,
width=10cm,
height=7cm,
scale only axis,
every x tick label/.append style={font=\scriptsize\color{gray!80!black}},
xmajorgrids,
xminorgrids,
every y tick label/.append style={font=\scriptsize\color{gray!80!black}},
ymajorgrids,
yminorgrids
}
\begin{axis}[%
xmin=0, xmax=40000,
xlabel={Time},
ymin=-50, ymax=50,
ylabel={Power},
axis y line*=left,
axis x line*=bottom]
\addplot [
color=red,
solid
]
coordinates{(0,0};
\label{pcharge}
\addplot [
color=green,
solid
]
coordinates{(0,0)};
\label{pbattery}
\end{axis}
\begin{axis}[%
xmin=0, xmax=40000,
ymin=0, ymax=100,
ylabel={State of charge},
axis lines=left,
axis y line*=right,
axis x line=none,
legend style={at={(1.15,1)},anchor=north west,nodes=right}]
\addplot [
color=blue,
solid
]
coordinates{(0,0)};
\addlegendentry{$SOC$};
\addlegendimage{/pgfplots/refstyle=pcharge}\addlegendentry{$P_\mathrm{charge}$};
\addlegendimage{/pgfplots/refstyle=pbattery}\addlegendentry{$P_\mathrm{battery}$};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
发生这种情况是因为您axis lines=left
在之前发出了axis y line*=right
。如果您删除axis lines=left
,箭头就会消失。这看起来像是一个错误,因此您可能需要提交错误报告。
\documentclass[border=5mm]{standalone}
\usepackage{graphics,siunitx}
\usepackage{tikz,pgfplots}
\begin{document}
\begin{tikzpicture}
\pgfplotsset{%
compat=1.6,
width=10cm,
height=7cm,
scale only axis,
every x tick label/.append style={font=\scriptsize\color{gray!80!black}},
xmajorgrids,
xminorgrids,
every y tick label/.append style={font=\scriptsize\color{gray!80!black}},
ymajorgrids,
yminorgrids
}
\begin{axis}[%
xmin=0, xmax=40000,
xlabel={Time},
ymin=-50, ymax=50,
ylabel={Power},
axis y line*=left,
axis x line*=bottom]
\addplot [
color=red,
solid
]
coordinates{(0,0)};
\label{pcharge}
\addplot [
color=green,
solid
]
coordinates{(0,0)};
\label{pbattery}
\end{axis}
\begin{axis}[%
xmin=0, xmax=40000,
ymin=0, ymax=100,
ylabel={State of charge},
axis y line*=right,
axis x line=none,
legend style={at={(1.15,1)},anchor=north west,nodes=right}]
\addplot [
color=blue,
solid
]
coordinates{(0,0)};
\addlegendentry{$SOC$};
\addlegendimage{/pgfplots/refstyle=pcharge}\addlegendentry{$P_\mathrm{charge}$};
\addlegendimage{/pgfplots/refstyle=pbattery}\addlegendentry{$P_\mathrm{battery}$};
\end{axis}
\end{tikzpicture}
\end{document}