你能确认一下这个错误吗?
\documentclass{standalone}
\usepackage{tikz,pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=middle,xmin=0,ymin=0]
\addplot[fill,opacity=0.5,cyan,domain=0:5,smooth] % smooth breaks \closedcycle
{1/x} \closedcycle;
\draw[-latex] (axis cs:3,2) node[label=above:Oops!] {} --
(axis cs:4.9,0.15) node[circle,draw=red,dashed,inner sep=5pt] {};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
是的,看起来像是一个错误。你可能需要提交错误报告。
-- (current plot end|-{rel axis cs:1,0}) \closedcycle
您可以使用而不是仅仅 来获得正确的平滑图\closedcycle
。
\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=middle,xmin=0, xmax=6, ymin=0, axis on top]
\addplot[fill,opacity=0.5,cyan,domain=0.2:5,smooth]
{1/x} -- (current plot end|-{rel axis cs:1,0}) \closedcycle;
\end{axis}
\end{tikzpicture}
\end{document}