
我正在使用循環列表和\addplot+
命令以不同的樣式繪製線條。我想使用每種樣式繪製一些內容,但是如下所示:
% Plot using style 1
\addplot+ coordinates {...};
\addplot coordinates {...};
\addlegendentry{Style 1}
% Plot using style 2
\addplot+ coordinates {...};
\addplot coordinates {...};
\addlegendentry{Style 2}
我怎樣才能做到這一點?
答案1
forget plot
key 是執行此操作的常用方法,但\addlegendentry{}
不選擇它addplot
後面的命令。您必須在開始時連續繪製傳說中的(!?)圖。因此,您可以整理這些圖,以便按照以下樣式繪製它們 1-2-3,1-2-3
\begin{tikzpicture}
\begin{axis}
% Plot using style 1
\addplot {ln(x)};\addlegendentry{Style 1}
\addplot {3*x};\addlegendentry{Style 2}
\pgfplotsset{cycle list shift=-2} % Goes two styles back
\addplot {0.5*x}; %Style 1
\addplot {2*x}; %Style 2
\end{axis}
\end{tikzpicture}
答案2
沒關係,我自己似乎在pfdplot 手冊第 4.25 節“雜項選項”,特別是forget plot
選項:
% Plot using style 1
\addplot+ [forget plot] coordinates {...};
\addplot+ coordinates {...};
\addlegendentry{Style 1}
% Plot using style 2
\addplot+ [forget plot] coordinates {...};
\addplot+ coordinates {...};
\addlegendentry{Style 2}