
パラメトリック曲線の垂直部分に矢印を描画したいと思います。たとえば、次のトロコイドを考えてみましょう。
\documentclass{scrbook}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{
arrows.meta
, bending
, decorations.markings
}
\pgfplotsset{compat = 1.17}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
width = 0.4\textwidth
, height = 0.25\textwidth
, axis equal
, axis lines = middle
, enlargelimits = false
, tick style = {draw = none}
, ymin = {0.0}
, xtick = \empty
, ytick = \empty
]
\addplot+[
no markers
, thick
, domain = -2.08869:8.37188
, smooth
, postaction = {decorate}
, decoration = {
markings
, mark = at position 0.132010 with {\arrow{Stealth[length = 2mm, bend]}}
, mark = at position 0.210413 with {\arrow{Stealth[length = 2mm, bend]}}
}
] ({x - 1.5 * sin(x r)}, {1.5 - 1.5 * cos(x r)});
\end{axis}
\end{tikzpicture}
\end{document}
対応する積分を計算し、曲線の「垂直」部分の位置が、全体の長さの割合として表される 0.132 と 0.210 であることがわかりました。矢印の先端が配置されている場所がここであるため、結果は醜く見えます。
矢印の先端ではなく、これらの点に矢印の中心を配置するにはどうすればよいでしょうか?
また、もう一つ質問ですが、「曲げる」と指定したのですが、まったく曲がっているようには見えません。なぜでしょうか?
答え1
マークの長さを明示的に定義しているので、\arrow
を使用できます。§24.4.1decoration tranform
を参照してくださいpgfmanual
。今回のケースでは、矢印を半分の長さだけシフトしました。
これが出力です。青色があなたのプロット、赤色がふるいにかけたプロットです。
% arara: lwpdflatex
\documentclass{scrbook}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{
arrows.meta
, bending
, decorations.markings
}
\pgfplotsset{compat = 1.17}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
width = 0.4\textwidth
, height = 0.25\textwidth
, axis equal
, axis lines = middle
, enlargelimits = false
, tick style = {draw = none}
, ymin = {0.0}
, xtick = \empty
, ytick = \empty
]
\addplot+[
no markers
, thick
, domain = -2.08869:8.37188
, smooth
, trig format=rad
, postaction = {decorate}
, decoration = {
markings
, mark = at position 0.132010 with {\arrow{Stealth[length = 2mm, bend]}}
, mark = at position 0.210413 with {\arrow{Stealth[length = 2mm, bend]}}
}
] ({x - 1.5 * sin(x)}, {1.5 - 1.5 * cos(x)});
\addplot+[
no markers
, thick,opacity=0.5
, domain = -2.08869:8.37188
, smooth
, trig format=rad
, postaction = {decorate}
, decoration = {
markings
, transform={xshift=1mm}
, mark = at position 0.132010 with {\arrow{Stealth[length = 2mm, bend]}}
, mark = at position 0.210413 with {\arrow{Stealth[length = 2mm, bend]}}
}
] ({x - 1.5 * sin(x)}, {1.5 - 1.5 * cos(x)});
\end{axis}
\end{tikzpicture}
\end{document}