如果我有ybar stacked
轴类型,我该如何添加另一个图(例如,jump plot
在顶部)?
下面的例子或多或少显示了我所需要的:
答案1
您可以使用以下方法关闭单个图的堆叠stack plots=false
:
\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\pgfplotsset{
colormap={whitered}{color(0cm)=(white); color(1cm)=(orange!75!red)}
}
\begin{tikzpicture}
\begin{axis}[
samples=10,
ybar stacked,
ymin=0,
set layers
]
\addplot +[white, draw=black] {rnd};
\addplot +[gray!50, draw=black] {rnd};
\addplot [
very thick, red!75!black,
const plot,
stack plots=false,
on layer=axis foreground
] {rnd};
\end{axis}
\end{tikzpicture}
\end{document}