2

I'm using the following code to draw a simple graph and colour in the area under it. The expected result would be a fully filled-in area under the curve. The actual result is that the colouring is being clipped diagonally:

enter image description here

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat = newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xmin = 0.0, xmax = 1.0, ymin = 0.0, ymax = 1.0, enlarge x limits = 0.25, enlarge y limits = 0.25, axis x line = middle, axis y line = middle, x label/.append style = {at = {(current axis.right of origin)}, anchor = south west}, y label/.append style = {at = {(current axis.above origin)}, anchor = north west}, legend/.append style = {font = \small}, xtick = {0.3, 0.6}, xticklabels = {$\varphi_{1}$, $\varphi_{2}$}, ymajorticks = false, yminorticks = false, xlabel = $\varphi$, ylabel = $r$, name = polar]
\path [name path = axis] (axis cs:0,0) -- (axis cs:1,0);
\addplot [name path = r, smooth, mark = *] coordinates {
    (0.3, 0.6)
    (0.4, 0.65)
    (0.6, 0.5)
};
\addplot [fill = orange] fill between [of = r and axis, soft clip = {domain=0.3:0.6}];
\draw [dashed] (0.3, 0.6) -- (0.3, 0.6 |- {rel axis cs:0, 0});
\draw [dashed] (0.6, 0.5) -- (0.6, 0.5 |- {rel axis cs:0, 0});
\end{axis}
\end{tikzpicture}
\end{document}

Please advise.

4
  • Welcome to TeX.SE! On my updated TeXLive2018 distribution I get the expected result, i.e. the complete shape is filled. When was the last time you updated your distribution? Which compiler do you use?
    – user121799
    Oct 26, 2018 at 14:35
  • I'm using LuaLaTeX from the TeX Live distribution from Arch Linux official package repository, updated to the latest available version (the version string is Version 1.07.0 (TeX Live 2018/Arch Linux)) and PGFPlots v1.16. Oct 26, 2018 at 14:52
  • I confirm your observation. However, with pdflatex there's no problem. So this seems to be a tricky thing.
    – user121799
    Oct 26, 2018 at 14:57
  • I can confirm that using pdfLaTeX produces the expected results. However, it's unlikely that I will be able to make that transition for my actual work (and it doesn't resolve the issue as-is). Oct 26, 2018 at 15:00

1 Answer 1

4

I have no real solution for you but only a workaround. It seems that with lualatex there is rounding error problem. If you decrease the lower bound of the soft clip a tiny bit, it seems to work.

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat = newest}

\begin{document}
\begin{tikzpicture}
\begin{axis}[xmin = 0.0, xmax = 1.0, ymin = 0.0, ymax = 1.0, enlarge x limits = 0.25, enlarge y limits = 0.25, axis x line = middle, axis y line = middle, x label/.append style = {at = {(current axis.right of origin)}, anchor = south west}, y label/.append style = {at = {(current axis.above origin)}, anchor = north west}, legend/.append style = {font = \small}, xtick = {0.3, 0.6}, xticklabels = {$\varphi_{1}$, $\varphi_{2}$}, ymajorticks = false, yminorticks = false, xlabel = $\varphi$, ylabel = $r$, name = polar]
\path [name path = axis] (axis cs:0,0) -- (axis cs:1,0);
\addplot [name path = r, smooth, mark = *] coordinates {
    (0.3, 0.6)
    (0.4, 0.65)
    (0.6, 0.5)
};
\addplot [fill = orange] fill between [of = r and axis, soft clip =
{domain=0.299:0.6}];
\draw [dashed] (0.3, 0.6) -- (0.3, 0.6 |- {rel axis cs:0, 0});
\draw [dashed] (0.6, 0.5) -- (0.6, 0.5 |- {rel axis cs:0, 0});
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

I stress that this is at best a workaround.

4
  • Thanks. I stumbled upon this workaround myself but, since this can't really be considered a proper solution for the problem, I went here looking for the latter. This is, however, what I'm using in my actual paper, and probably will have to suffice until resolved. Oct 26, 2018 at 15:05
  • @AretsPaeglis I fully agree. I myself have a problem with the updated lualatex, see here. I am not claiming that these things are necessarily related, but want to mention that Feynman diagram problem has not been resolved either so far. And I fully agree that you should wait for a real solution, yet it may not come before you submit your paper.
    – user121799
    Oct 26, 2018 at 15:09
  • To be fair, from a purely reader's point of view the deviation of 0.001 isn't noticeable in the final PDF even under 400x magnification, so in practical terms the problem as such could be considered fixed. The issue itself, however, remains and might crop up in other situations where rounding errors influence the output. Oct 26, 2018 at 15:13
  • 1
    @AretsPaeglis I pinged some lualatex experts in the chat, so let's keep our fingers or claws crossed. ;-)
    – user121799
    Oct 26, 2018 at 15:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .