如何使 y 轴上的箭头完整可见
\documentclass[tikz]{standalone}
\usetikzlibrary{arrows.meta,decorations.markings}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}[declare function={f(\x)=4-0.5*(\x-2)*(\x-2);}]
\begin{axis}[grid=minor, xmin=0, xmax=5, ymin=0, ymax=4.5,
xlabel=$x$, ylabel={$y$},
xtick = {}, ytick = {},
scale=1, restrict y to domain=0:4.5]
\draw[purple,thick,>={Stealth[round]},postaction=decorate,
decoration={markings,
mark=at position 0.125 with {\arrow[black]{>}},
mark=at position 0.4 with {\arrow[black]{>.>}},
mark=at position 0.7 with {\arrow[black]{>}},
mark=at position 0.925 with {\arrow[black]{>.>}},
}] (0,4) --
(0,{f(4.65)}) -- plot[variable=\x,domain=4.65:2]
(\x,{f(\x)}) -- cycle;
\end{axis}
\end{tikzpicture}
\end{document}
答案1
只需使用 关闭剪辑即可clip=false
。
\documentclass[tikz]{standalone}
\usetikzlibrary{arrows.meta,decorations.markings}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}[declare function={f(\x)=4-0.5*(\x-2)*(\x-2);}]
\begin{axis}[grid=minor, xmin=0, xmax=5, ymin=0, ymax=4.5,
xlabel=$x$, ylabel={$y$},
xtick = {}, ytick = {},
scale=1, restrict y to domain=0:4.5,clip=false]
\draw[purple,thick,>={Stealth[round]},postaction=decorate,
decoration={markings,
mark=at position 0.125 with {\arrow[black]{>}},
mark=at position 0.4 with {\arrow[black]{>.>}},
mark=at position 0.7 with {\arrow[black]{>}},
mark=at position 0.925 with {\arrow[black]{>.>}},
}] (0,4) --
(0,{f(4.65)}) -- plot[variable=\x,domain=4.65:2]
(\x,{f(\x)}) -- cycle;
\end{axis}
\end{tikzpicture}
\end{document}