# How to make Tufte style 'data based labels', showing the maximum and minimum of the data

I'm trying to make a graph where the maximum and minimum of the plotted data are reflected on an axis and the axis line stops after that value. Although sometimes I want noisy data to appear at larger/smaller values.

I tried to offset the axis as was suggested in this post. The problem you can see is that in this case I want the axis to go from -0.1 to -0.7 with ticks at these positions. The problem is that if you have noisy data it gets clipped after ymin and ymax.

I've provided a manually edited example on the bottom.

\documentclass{standalone}
\usepackage{pgfplots}

\newlength\xaxisoffset
\setlength\xaxisoffset{-10pt}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
every non boxed x axis/.style={ %Shifts the x axis downwards
x axis line style={yshift=\xaxisoffset},
xticklabel style={yshift=\xaxisoffset},
xtick style={very thin,yshift=\xaxisoffset},
},
xmin = -.09, xmax=.09,
axis x line=bottom,
axis y line*=left,
ymin = -0.7, ymax = -0.08,
ytick={-.1, -.7},
]
\end{axis};
\end{tikzpicture}
\end{document}


• Clipping can be disabled by option clip=false.
• The order of magnitude of the x labels (·10-2) is moved down twice; x tick scale label style={yshift=-\xaxisoffset} compensates it.

Full example file:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}

\newlength\xaxisoffset
\setlength\xaxisoffset{-40pt}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
clip=false,
every non boxed x axis/.style={% Shifts the x axis downwards
x axis line style={yshift=\xaxisoffset},
xticklabel style={yshift=\xaxisoffset},
x tick scale label style={yshift=-\xaxisoffset},
xtick style={very thin,yshift=\xaxisoffset},
},
xmin = -.09, xmax=.09,
axis x line=bottom,
axis y line*=left,
ymin = -0.7, ymax = -0.1,
ytick={-.1, -.7},
]