プロットを中断するにはどうすればいいですか?

プロットを中断するにはどうすればいいですか?

次のサンプルコードを検討してください。

\documentclass{article}
\usepackage{pgfplotstable}

\pgfplotstableread{
1   19.178  26.027  8.219   6.849   39.726  1
2   54.795  21.918  4.110   6.849   12.329  1
3   28.767  16.438  6.849   8.219   39.726  1
4   63.014  2.740   2.740   8.219   28.767  2
5   90.411  1.370   6.849   0.000   1.370  2
6   15.068  2.740   16.438  8.219   57.534  2
7   67.123  0.000   0.000   1.000   32.877  3
8   72.603  6.849   5.479   5.000   15.068  3
9   56.164  12.329  6.849   4.110   20.548  3
10  50.685  4.110   8.219   1.370   35.616  3
}\datatable

\begin{document}

\begin{tikzpicture}
\begin{axis}
\addplot table[x index=0,y index=4] \datatable;
\end{axis}
\end{tikzpicture}

\end{document}

制作

ここに画像の説明を入力してください

私がやりたいのは、ストーリーを中断することです。テーブルを変更せずに(可能であれば)、希望する場所で、次のような画像を取得します (接続線の一部を手動で消去して画像を取得しました)。

ここに画像の説明を入力してください

理想的には、これを 1 つだけで実行したいのです\addplotが、それが不可能な場合は、代替案を歓迎します。

答え1

2つの選択肢が考えられます:

1)テーブルを変更できる場合簡単な修正方法は、何らかの未定義データを追加して、オプションを使用することですunbounded coords=jump。「nan」または「inf」のどちらでも機能します。結果はまさにあなたが望んでいるとおりなので、投稿しません。

\documentclass{article}
\usepackage{pgfplotstable}

\pgfplotstableread{
1   19.178  26.027  8.219   6.849   39.726  1
2   54.795  21.918  4.110   6.849   12.329  1
3   28.767  16.438  6.849   8.219   39.726  1
nan   nan  nan  nan   nan   nan  nan
4   63.014  2.740   2.740   8.219   28.767  2
5   90.411  1.370   6.849   0.000   1.370  2
6   15.068  2.740   16.438  8.219   57.534  2
nan
7   67.123  0.000   0.000   1.000   32.877  3
8   72.603  6.849   5.479   5.000   15.068  3
9   56.164  12.329  6.849   4.110   20.548  3
10  50.685  4.110   8.219   1.370   35.616  3
}\datatable

\begin{document}

\begin{tikzpicture}
\begin{axis}[unbounded coords=jump]
\addplot table[x index=0,y index=4] \datatable;
\end{axis}
\end{tikzpicture}

\end{document}

2)テーブルを変更できない場合プロットを分割して定義することをお勧めしますdomains。これは問題がないわけではありません。なぜなら、これらのフォーマットを繰り返す必要があるからです(例:[red, solid, thick,...])

\begin{tikzpicture}
\begin{axis}
\addplot+[forget plot] table[x index=0,y index=4, restrict x to domain=0:3] \datatable;
\addplot+[forget plot] table[x index=0,y index=4, restrict x to domain=4:6] \datatable;
\addplot+[           ] table[x index=0,y index=4, restrict x to domain=7:10] \datatable;
\end{axis}
\end{tikzpicture}

関連情報