In this TUGBoat article the author show how to implement tufte style plots with pgfplots.
Currently I am working with Lualatex,texlive 2015.
In the following MWE I implemented the idea from the paper. However, it happens sometimes that I would like to fix the xmin,xmax ymax and ymin of the plot, keeping the axis length given by data@xmin,data@xmax etc . However the following behaviour is observed:
- If only data with error bars is plotted the result is good (in the MWE, comment out the second plot).
If only data without errors bar is plotted, the compilation takes forever and never stops. (in the MWE comment out the first plot)
If plotted together, the code works but for the black-axis length are wrong, as you can see in the picture. The y black line should go up to ymax of the red line, and similarly with the x-line.
How can I solve 2. and 3.?
MWE:
\documentclass{standalone}
\usepackage{verbatim}
\usepackage{pgfplots}
\usepackage{lmodern}
\pgfplotsset{compat = newest}
\pgfplotsset{
every axis legend/.append style =
{
cells = { anchor = east },
draw = none
},
}
\makeatletter
\pgfplotsset{
tufte axes/.style =
{
after end axis/.code =
{
\draw ({rel axis cs:0,0} -| {axis cs:\pgfplots@data@xmin,0}) -- ({rel axis cs:0,0} -| {axis cs:\pgfplots@data@xmax,0});
\draw ({rel axis cs:0,0} |- {axis cs:0,\pgfplots@data@ymin}) -- ({rel axis cs:0,0} |-{axis cs:0,\pgfplots@data@ymax});
},
axis line style = {draw = none},
tick align = outside,
tick pos = left
},
}
\makeatother
\begin{document}
\begin{tikzpicture}
\pgfplotsset{every axis plot post/.append style={mark=none}}
\pgfplotsset{every axis plot post/.append style={line width=1.pt}}
\begin{axis}[tufte axes,ylabel near ticks,scaled y ticks=false,ymajorgrids,unbounded coords=jump,legend pos= outer north east,legend style={font=, line width=1.pt}, xmin=6.,xmax=11,ymin=5000,ymax=7000,
xlabel={x},
ylabel={y},]
%
\addplot+[thick,mark size=2,error bars/.cd,y dir=both,y explicit]
coordinates {
(7.846, 5614.5) +- (110., 110.)
(8.096, 5530.) +- (69., 69.)
(8.65, 5442.) +- (57., 57.)
};
\addlegendentry{a}
\addplot+[thick,mark=none]
coordinates {
(7.5, 6319.2)
(9.03, 5996.6)
};
\addlegendentry{b}
\end{axis}
\end{tikzpicture}
\end{document}