3

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}
Stefan Pinnow
  • 29,535
masher
  • 362
  • 1
    Looks like a bug to me -- bizarrely it works fine with 0.352 instead of 0.35 – Thruston Apr 29 '16 at 11:30
  • Yep. With those page settings, having a width of 0.35 or less disappears my shading. Larger than that and it works. – masher Apr 29 '16 at 11:48
  • 1
    I agree with @Thruston that this is a bug. The console contains some error message claiming that the fill between failed to compute correctly. I'll add it to the pgfplots todo list. – Christian Feuersänger Apr 29 '16 at 14:10
  • @ChristianFeuersänger seems similar to http://tex.stackexchange.com/questions/283647/shaded-area-under-pgfplot-starting-with-first-data-point-outputs-wrong-shaded --- soft clip in both. – Rmano Apr 29 '16 at 16:30
  • For the record: This bug is reported to the PGFPlots Tracker as bug 139. – Stefan Pinnow Feb 21 '17 at 02:23
  • 5
    I'm voting to close this question because the bug was fixed in the just released PGFPlots v1.16. Thus, your MWE now works as expected. – Stefan Pinnow Apr 07 '18 at 04:54

0 Answers0