如何打斷劇情?

如何打斷劇情?

請考慮以下範例程式碼:

\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}

生產

在此輸入影像描述

我想做的就是打斷劇情,不修改表(如果可能的話),在所需的位置得到類似的東西(我通過手動擦除一些連接線來獲得圖像):

在此輸入影像描述

理想情況下,我只想用一個來完成此操作\addplot,但如果不可能,歡迎使用任何替代方案。

答案1

我可以想到兩個選擇:

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}

相關內容