
Ich möchte einen Pfeil am vertikalen Teil einer parametrischen Kurve zeichnen. Betrachten Sie beispielsweise die folgende Trochoida.
\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}
Ich habe die entsprechenden Integrale berechnet und weiß, dass die Positionen der „vertikalen“ Teile der Kurve 0,132 und 0,210 betragen, ausgedrückt als Bruchteil der Gesamtlänge. Das Ergebnis sieht hässlich aus, denn hier befinden sich die äußersten Spitzen der Pfeile:
Wie platziert man an diesen Punkten die Mitte des Pfeils und nicht sein spitzes Ende?
Noch eine Nebenfrage: Ich habe „Bend“ angegeben, aber es sieht überhaupt nicht nach Biegung aus. Warum?
Antwort1
Da Sie die Länge der \arrow
Markierungen explizit definieren. Sie könnten ein verwenden decoration tranform
, siehe pgfmanual
§24.4.1. Im vorliegenden Fall habe ich die Pfeile um ihre halbe Länge verschoben.
Hier ist die Ausgabe, mit Ihrem Diagramm in Blau und dem gesiebten in halbtransparentem Rot.
% 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}