I'm plotting some distribution functions for my students, and I am shading regions of the plots. If I reduce the plot width to 0.35\textwidth or less, the shading disappears.
How do I ensure that it all stays put?
I've included all of my page setup in case there is an issue there.
\documentclass[11pt, twoside]{book} % use larger type; default would be 10pt
\usepackage{geometry} % to change the page dimensions
\geometry{a4paper} % or letterpaper (US) or a5paper or....
\geometry{lmargin=30mm, rmargin=10mm,tmargin=20mm,bmargin=20mm}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.13}
\usepgfplotslibrary{fillbetween}
\begin{document}
\pgfmathdeclarefunction{FuncUniform}{3}{%
\pgfmathparse{and(#1>(#2- #3), #1<(#2+ #3)) * (1/(2* #3))}%
}
\begin{tikzpicture}
\begin{axis}[
axis lines = left,
every outer x axis line/.append style= {-},
every outer y axis line/.append style= {-},
width={0.35\textwidth}, height={0.35\textwidth}, %this line is the issue
]
\addplot[domain=-5:5, samples=501, name path=U,] {FuncUniform(x,0,3)};
\addplot[domain=-5:5, samples=3, name path=Xaxis,] {0};
\addplot[lightgray] fill between[of=U and Xaxis, soft clip={domain=-1.732:1.732},];
\end{axis}
\end{tikzpicture}
\end{document}
0.352instead of0.35– Thruston Apr 29 '16 at 11:30fill betweenfailed to compute correctly. I'll add it to thepgfplotstodo list. – Christian Feuersänger Apr 29 '16 at 14:10soft clipin both. – Rmano Apr 29 '16 at 16:30