I want to show narrow segments out of a large spectrum. Since it is one spectrum, I want to use one single plot, but hide the irrelevant parts. To make clear that I show disconnected parts, I want to use discontinued axis lines between the parts. The code example shows how far I came (based on an example from the manual):
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.7}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis x line=bottom,
axis x discontinuity=parallel,
axis y line=left,
xmin=360, xmax=600,
ymin=0, ymax=7,
enlargelimits=false
]
\addplot coordinates {
(420,2)
(500,6)
(590,4)
};
\end{axis}
\end{tikzpicture}
\newpage
\begin{tikzpicture}
\begin{axis}[
axis x line=bottom,
axis y line=left,
ymin=0, ymax=7,
enlargelimits=false
]
\addplot coordinates {
(420,2)
(500,6)
(590,4)
};
\addplot coordinates {
(25420,2)
(25500,6)
(25590,4)
};
\addplot coordinates {
(50420,2)
(50500,6)
(50590,4)
};
\end{axis}
\end{tikzpicture}
\newpage
\begin{tikzpicture}
\begin{axis}[
axis x line=bottom,
axis y line=left,
xmin=400, xmax=1200,
ymin=0, ymax=7,
enlargelimits=false
]
\addplot+ coordinates {
(420,2)
(500,6)
(590,4)
};
\end{axis}
\begin{axis}[
axis x line=none,
axis y line=none,
xmin=25100, xmax=25900,
ymin=0, ymax=7,
enlargelimits=false
]
\addplot+ coordinates {
(25420,2)
(25500,6)
(25590,4)
};
\end{axis}
\begin{axis}[
axis x line=none,
axis y line=none,
xmin=49800, xmax=50600,
ymin=0, ymax=7,
enlargelimits=false
]
\addplot coordinates {
(50420,2)
(50500,6)
(50590,4)
};
\end{axis}
\end{tikzpicture}
\end{document}
The code leads to these results:
How can I discontinue the x axis and mark the discontinuities similar to the first plot, but between the parts?
Edit:
Fortunately, I was able to solve parts of the problem, but it's a very “hackish” solution:
\documentclass[tikz,convert]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.7}
\usepgfplotslibrary{units}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
name=a,
width=.25\linewidth,
height=5cm,
axis x line=box,
axis y line*=left,
xmin=350, xmax=750,
ymin=0, ymax=7,
xticklabels={,,0.4,,,0.7},
]
\addplot+ coordinates {
(420,2)
(500,6)
(590,4)
};
\end{axis}
\begin{axis}[
name=b,
width=.25\linewidth,
height=5cm,
xshift=2cm,
axis x line=box,
axis y line=none,
xmin=25350, xmax=25750,
ymin=0, ymax=7,
xticklabels={,,25.4,,,25.7},
change x base,
x SI prefix=kilo,
]
\addplot+ coordinates {
(25420,2)
(25500,6)
(25590,4)
};
\end{axis}
\begin{axis}[
name=c,
width=.25\linewidth,
height=5cm,
xshift=4cm,
axis x line=box,
axis y line*=right,
xmin=50350, xmax=50750,
ymin=0, ymax=7,
xticklabels={,,50.4,,,50.7},
yticklabel=\empty,
scaled x ticks=base 10:-3
]
\addplot+ coordinates {
(50420,2)
(50500,6)
(50590,4)
};
\end{axis}
\draw [dotted] (a.south east) -- (b.south west);
\draw [dotted] (a.north east) -- (b.north west);
\draw [dotted] (b.south east) -- (c.south west);
\draw [dotted] (b.north east) -- (c.north west);
\end{tikzpicture}
\end{document}
Result:
With that solution, automatic scaling to \linewidth
does not work and everything has to be done by hand, especially the line style. Is there some way to optimize and automate it?
axis
statement. I'll try to improve my own solution and post updates here.ymin
andymax
or omit them.