I want to plot a graph and show only the low x-positions and the high x-positions. Right now I use two times \addplot with restrict x domain to achieve this:
\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat = newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xmin=-3, xmax=5]
\addplot[restrict x to domain=-3:-1]
coordinates {
(-3, 8.31160034e-02)
(-2, 2.54685628e-02)
(-1, 7.40715288e-03)
(0, 2.10192154e-03)
(1, 5.87352989e-04)
(2, 1.62269942e-04)
(3, 3.40715288e-03)
(4, 7.40715288e-03)
(5, 2.40715288e-02)
};
\addplot[restrict x to domain=1:5]
coordinates {
(-3, 8.31160034e-02)
(-2, 2.54685628e-02)
(-1, 7.40715288e-03)
(0, 2.10192154e-03)
(1, 5.87352989e-04)
(2, 1.62269942e-04)
(3, 3.40715288e-03)
(4, 7.40715288e-03)
(5, 2.40715288e-02)
};
\end{axis}
\end{tikzpicture}
\end{document}

I wonder if the trick can also be done with just one \addplot?

restrict expr to domain={(x>=a1)*(x<=b1)+(x>=a2)*(x<=b2)}{1:+inf}wouldn't it be enough to restrict the range to{1:1}(for a1<b1<a2<b2)? – Christine Jan 12 '15 at 12:15{1:1}would be good enough. However, you decided to change one endpoint and overlapping then occurred you might get surprised. – Andrew Swann Jan 12 '15 at 19:44