pgfplots ライン プロットの 2 つの座標間の線を削除します。

pgfplots ライン プロットの 2 つの座標間の線を削除します。

この特定のトピックに関する投稿は見つかりませんが、私の問題は特別なものではないと思います。私が見つけていないスレッドが既にある場合は、お知らせください。

そこで、 を使用して通貨価値のプロットを作成しようとしていますpgfplots。ただし、時系列の途中で通貨が変更されたため、1990 年から 2000 年までの線が描画されないように、線を中断したいと思います。これらの単一の線を削除するにはどうすればよいですか?

私の例は次のとおりです:

\begin{figure}
\centering
\begin{tikzpicture}
  \begin{axis}[width=\textwidth, xlabel = year,%\,/\,Tsd. Tonnen,
      xmin = 1965, xmax = 2015,
      xtick={1960, 1970, 1980, 1990, 2000, 2010},
      x tick label style={/pgf/number format/1000 sep=},
      ylabel = example,
      ymin = 1000, ymax = 5000,
      y tick label style={/pgf/number format/1000 sep=},]
      \addplot 
      coordinates {
(1960,  1650)
(1970,  2550)
(1980,  4050)
(1990,  4550)
(2000,  3550)
(2010,  3750)
         };
       \addplot 
      coordinates {
(1960,  1600)
(1970,  2500)
(1980,  4000)
(1990,  4500)
(2000,  3500)
(2010,  3700)
         };
\legend{a, b}
   \end{axis}
\end{tikzpicture}
\vspace*{0.4cm} 
\caption[Example.]{Example.}
\end{figure}

そして、その写真は次のようになります。

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

ご協力いただければ幸いです! :)

答え1

unbounded coords=jump1 つの方法は、オプションに を追加しaxisnan1990 年から 2000 年の間のどこかに座標を追加することです。以下に(1995, nan)、たとえば を追加しました。

あるいは、時系列を 2 つに分割することもできます\addplotが、その場合、プロット スタイルが同じであることを確認する作業が増えます。

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

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[width=\textwidth, xlabel = year,%\,/\,Tsd. Tonnen,
      xmin = 1965, xmax = 2015,
      xtick={1960, 1970, 1980, 1990, 2000, 2010},
      x tick label style={/pgf/number format/1000 sep=},
      ylabel = example,
      ymin = 1000, ymax = 5000,
      y tick label style={/pgf/number format/1000 sep=},
      unbounded coords=jump  %%%% added
      ]
      \addplot 
      coordinates {
(1960,  1650)
(1970,  2550)
(1980,  4050)
(1990,  4550)
(1995, nan)
(2000,  3550)
(2010,  3750)
         };
       \addplot 
      coordinates {
(1960,  1600)
(1970,  2500)
(1980,  4000)
(1990,  4500)
(1995, nan)
(2000,  3500)
(2010,  3700)
         };
\legend{a, b}
   \end{axis}
\end{tikzpicture}

\end{document}

関連情報