[Tex/LaTex] Tufte like axis with pgfplots

axispgfplotstufte

How to achieve this kind of axis with pgfplot ? Image taken from Szymon Beczkowski's awesome PhD thesis design (thesis link)

Credit to Beczkowski, Szymon

I may provide you with some data to play with.

\documentclass{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[xlabel={$L$ [H]},ylabel={$\hat{I}_{DM}$ [A]},axis lines*=left,grid,xtick=data]
  \addplot coordinates {(948e-6,1.61981) (1.5e-3,1.02377) (2e-3,0.769047) (2.5e-3,0.614994) (3e-3,0.503511)};
\end{axis}
\end{tikzpicture}
\end{document}

Best Answer

You can shift your axes, ticks and labels to obtain the axis effect. Adjusting the color of the plot and the size of the marks, gets you closer to the general style. Labels may be added via nodes referencing points in the data coordinate system.

I have updated my previous answer to include new features of pgfplots and placed much of the code in a single tuftelike style. Many thanks to Christian Feuersänger for his continued work on the pgfplots package.

Sample output

\documentclass{article}

\usepackage{pgfplots}
\pgfplotsset{compat=1.13}

\pgfkeys{/pgfplots/tuftelike/.style={
  semithick,
  tick style={major tick length=4pt,semithick,black},
  separate axis lines,
  axis x line*=bottom,
  axis x line shift=10pt,
  xlabel shift=10pt,
  axis y line*=left,
  axis y line shift=10pt,
  ylabel shift=10pt}}

\begin{document}

\begin{tikzpicture}[every pin/.style={red!50!black,font=\small\sffamily}]
  \begin{axis}[tuftelike,
    xlabel={$L$ [H]},
    ylabel={$\hat{I}_{DM}$ [A]},
    enlarge x limits=false,
    xtick=data,
    ytick={0.4,0.6,...,1.801},
    ymin=0.4,ymax=1.8]
    \addplot[black,mark=*,mark size=1.5pt]
    coordinates{(948e-6,1.61981) (1.5e-3,1.02377) (2e-3,0.769047)
    (2.5e-3,0.614994) (3e-3,0.503511)};
    \node[coordinate,pin=above right:{2007}] at (axis cs:1.5e-3,1.02377) {};
  \end{axis}
\end{tikzpicture}

\end{document}

The form of the axis is obtained by using separate axis lines and the axis ... line* styles. Axis shifting is obtained via the axis ... line shift and ...label shift commands. These could be issued as one common command, but I have kept the x and y variants visible should you need to change them individually. Adjustment of tick styling and color is from the semithick and the tick style.

(The last ytick value is 1.801 instead of 1.8 because of rounding problems in the internal arithmetic.)

The code

[every pin/.style={red!50!black,font=\small\sffamily}]

provides the style for the label of the given point on the graph.

Related Question