In principle, you can use the mesh style for this: for line plots, this results in the line being drawn with individual segments, instead of using one continuous path. Then you can apply the shorten <=1mm, shorten >=1mm options to offset the start and end of the segments.

However, there's one implementation detail that hinders this: currently, PGFPlots uses \pgfusepathqstroke to draw the segments, which ignores all options like arrow tips or shortenings. So to make this work, we have to redefine an internal macro to instead use \pgfusepath{stroke}. Here's a key that takes care of that, and takes an optional argument for setting the gap length:
\makeatletter
\pgfplotsset{
discontinuous line/.code={
\pgfkeysalso{mesh, shorten <=#1, shorten >=#1,
legend image code/.code={
\draw [##1, shorten <=0cm] (0cm,0cm) -- (0.3cm,0cm);
\draw [only marks] plot coordinates {(0.3cm,0cm)};
\draw [##1, shorten >=0cm] (0.3cm,0cm) -- (0.6cm,0cm);
}}
\def\pgfplotsplothandlermesh@VISUALIZE@std@fill@andor@stroke{%
\pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{fill path}%
\pgfplotsplothandlermesh@definecolor
\pgfusepath{stroke}
\pgfplotsplothandlermesh@show@normals@if@configured
}%
},
discontinuous line/.default=1.5mm
}
\makeatother
Putting that code snippet in your preamble, after \usepackage{pgfplots}, allows you to get a discontinous line like this:
\begin{axis}
\addplot [discontinuous line, black, mark=*] table {
0 5
1 3
2 4
3 8
4 0
};
\addplot [discontinuous line=3mm, red, mark=*] table {
0 1
2 5.5
3 7.25
4 8
};
\end{axis}
Full code:
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\makeatletter
\pgfplotsset{
discontinuous line/.code={
\pgfkeysalso{mesh, shorten <=#1, shorten >=#1,
legend image code/.code={
\draw [##1, shorten <=0cm] (0cm,0cm) -- (0.3cm,0cm);
\draw [only marks] plot coordinates {(0.3cm,0cm)};
\draw [##1, shorten >=0cm] (0.3cm,0cm) -- (0.6cm,0cm);
}}
\def\pgfplotsplothandlermesh@VISUALIZE@std@fill@andor@stroke{%
\pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{fill path}%
\pgfplotsplothandlermesh@definecolor
\pgfusepath{stroke}
\pgfplotsplothandlermesh@show@normals@if@configured
}%
},
discontinuous line/.default=1.5mm
}
\makeatother
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis background/.style={
shade,bottom color=gray!50,top color=white
}
]
\addplot [discontinuous line, black, mark=*] table {
0 5
1 3
2 4
3 8
4 0
};
\addplot [discontinuous line=3mm, red, mark=*] table {
0 1
2 5.5
3 7.25
4 8
};
\end{axis}
\end{tikzpicture}
\end{document}