
내 문제가 고유한 것은 아니라고 생각하지만 이 특정 주제에 대한 게시물을 찾을 수 없습니다. 제가 찾지 못한 스레드가 이미 있다면 알려주시기 바랍니다.
그래서 를 이용하여 금전적 가치의 플롯을 만들려고 합니다 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=jump
한 가지 방법은 옵션 에 추가하고 1990년에서 2000년 사이 어딘가에 좌표 axis
를 추가하는 것 입니다. 예를 들어 nan
아래에 을 추가했습니다 .(1995, nan)
또는 시계열을 두 개로 분할할 수도 있지만 \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}