pgfplots を使用して、同じスタイル (サイクル リストを使用) で 2 本の線をプロットするにはどうすればよいですか?

pgfplots を使用して、同じスタイル (サイクル リストを使用) で 2 本の線をプロットするにはどうすればよいですか?

私はサイクル リストと\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キーはこれを行う通常の方法ですが、\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

気にしないでください。私は自分で答えを見つけたようですpfdplots マニュアルセクション 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}

関連情報