
パラメトリック曲線のパスに沿って方向矢印を追加しようとしています。以下の曲線を作成する方法がわかりました (赤い放物線は無視してください)。
\begin{document}
\section{2D Plots}
\begin{tikzpicture}
\begin{axis}[xmin=-10, xmax=10, ymin=-10, ymax=10,
axis lines=middle,
xlabel = $x$,
ylabel = $y$]
\addplot[color=red]{4-x^2};
\addplot[ domain=0:5*pi,
samples = 120, color = blue]
({2*cos(deg(2*x))},
{4*sin(deg(3*x)});
\end{axis}
\end{tikzpicture}
\end{document}
答え1
のドキュメントのセクションpgfplots
4.17.4 プロットの上に装飾を配置する。
Smooth
プロットは連続する点の間を滑らかに補間します。 を使用するとfpu
、より正確な veclen 関数を使用して、沿った装飾を行うことができます。
\documentclass[border=5mm]{standalone}
%https://tex.stackexchange.com/questions/717063/adding-direction-arrows-for-a-parametric-graph
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usetikzlibrary{decorations.markings,fpu}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xmin=-10, xmax=10, ymin=-10, ymax=10,
axis lines=middle,
xlabel = $x$,
ylabel = $y$]
\addplot[
/pgf/fpu/install only=veclen,smooth,%<-- added
blue,samples=127,domain=0:5*pi,
postaction={decorate},% ------
decoration={markings, % ------
mark=between positions .0 and 1. step .25 with {\arrow{stealth}},
% mark=at position 0.25 with {\arrow{stealth}},
% mark=at position 0.5 with {\arrow{stealth}},
% mark=at position 0.75 with {\arrow{stealth}}
}
]({2*cos(deg(2*x))},{4*sin(deg(3*x)});
\end{axis}
\end{tikzpicture}
\end{document}