如何正确使用循环列表=黑色白色

如何正确使用循环列表=黑色白色

我无法让黑白循环列表正常工作。所有三个图表都是实心黑线。但我希望它们有不同的虚线图案!

\documentclass[11pt, a4paper]{article}
\usepackage{pgfplots}
\begin{document}
\begin{figure} [!htbp]
\centering
\begin{tikzpicture}
\begin{axis}[
width=5in,
xlabel={Time},
ylabel={Displacement},
no markers,
yticklabel style={/pgf/number format/fixed},
cycle list name=black white,
]
\addplot+ table [x=time,y=disp_body,col sep=comma]{tables/data_static.csv};
\addplot+ table [x=time,y=disp_spring,col sep=comma]{tables/data_static.csv};
\addplot+ table [x=time,y=disp_tyre,col sep=comma]{tables/data_static.csv};
\addlegendentry{Car body}
\addlegendentry{Spring}
\addlegendentry{Tyre}
\end{axis}
\end{tikzpicture} 
\caption{Determination of static deflections}
\label{fig_static}
\end{figure}
\end{document}

答案1

您的代码没有任何问题(尽管我不会添加独立的加号,或者我也会添加[])。它们之所以显示为静态,是因为前 5 个循环定义带有实线和不同的标记,而您已将其关闭。来自手册

在此处输入图片描述

如果您移动循环列表,您将看到它运行正常。

\documentclass[11pt, a4paper]{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
no markers,
cycle list name=black white,
]
\addplot+[] {rand};\pgfplotsset{cycle list shift=4}
\addplot+[] {rand};
\end{axis}
\end{tikzpicture} 
\end{document}

在此处输入图片描述

相关内容