Tikz: 간격을 건너뛰도록 축 변환

Tikz: 간격을 건너뛰도록 축 변환

두 개의 그래프가 다이어그램에 표시되어 있는데, 그 사이에 공간이 꽤 많아서 보기 흉합니다. 사이의 공간을 건너뛰어 서로 더 가깝게 이동하고 싶습니다.

이것은 다이어그램입니다

\documentclass{standalone}
\usepackage{tikz,pgfplots}

\begin{document}
\begin{tikzpicture} 
\pgfplotsset{
    scale only axis}
\begin{axis}[tick align=center,xmin=546, xmax=565, ymin=0, ymax=60]
\addplot[line width=1pt]
coordinates{(564,0)(563,10)(562,20)(561,30)(560,40)(559,50)(558,60)}; 
\addplot[dotted,line width=1pt]
coordinates{(552,0)(551,10)(550,20)(549,30)(548,40)(547,50)(546,60)};
\end{axis}
\end{tikzpicture}
\end{document}

그리고 이것이 제가 x축을 상상하는 방법입니다:

\documentclass{standalone}
\usepackage{tikz,pgfplots}

\begin{document}
\begin{tikzpicture}
\foreach \x/\y in {0/550, 1/552, 4/556, 5/558}
\draw (\x,0.25) -- (\x,-0.25) node[below]{$\y$};
\draw (-0.5, 0)--(2,0);
\draw (3, 0)--(5.5,0);
\draw[dotted] (2,0)--(3,0);
\end{tikzpicture}
\end{document}

답변1

이것은 거의 전적으로 다음에서 가져온 것입니다.이 답변. 물론 x과 의 역할을 교환 y한 다음 ymin과 가 과 가 ymax되어야 합니다 .xminxmax스테판 핀노(Stefan Pinnow)가 언급함.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16,scale only axis}
\usepgfplotslibrary{groupplots}
\begin{document}
\begin{tikzpicture} 
\begin{groupplot}[width=6cm,
    group style={
        group name=my fancy plots,
        group size=2 by 1,
        %xticklabels at=edge bottom,
        horizontal sep=0pt
    },
    ]

\nextgroupplot[tick align=center,xmin=545, xmax=553, ymin=0, ymax=60,
axis y line=left]
\addplot[line width=1pt]
coordinates{(564,0)(563,10)(562,20)(561,30)(560,40)(559,50)(558,60)}; 
\addplot[dotted,line width=1pt]
coordinates{(552,0)(551,10)(550,20)(549,30)(548,40)(547,50)(546,60)};
\nextgroupplot[tick align=center,xmin=557, xmax=565, ymin=0, ymax=60,
axis x discontinuity=crunch,axis y line=right,ytick=\empty,
xtick={560,562,564}]
\addplot[line width=1pt]
coordinates{(564,0)(563,10)(562,20)(561,30)(560,40)(559,50)(558,60)}; 
\addplot[dotted,line width=1pt]
coordinates{(552,0)(551,10)(550,20)(549,30)(548,40)(547,50)(546,60)};
\end{groupplot}
\end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

관련 정보