Horizontale Bewegung eines gedrehten Etiketts in PGFPLOTS

Horizontale Bewegung eines gedrehten Etiketts in PGFPLOTS

Im folgenden Code habe ich an einer der Pfeilspitzen eine lange Beschriftung. Ich möchte die Beschriftung um 90 Grad drehen und dann direkt unter der Pfeilspitze platzieren. Ich habe die rotateOption und die posOption verwendet, um die Beschriftung vertikal zu drehen und zu verschieben. Wie kann ich die Beschriftung horizontal nach rechts verschieben, sodass sie direkt unter der Pfeilspitze angezeigt wird?

\documentclass[12pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
   scale=5,
   anchor=origin, 
   axis x line=middle,
   axis y line=middle,
   every axis x label/.style={at={(current axis.right of origin)},anchor=west},
   every axis y label/.style={at={(current axis.above origin)},anchor=south},
    enlarge x limits=0.05,
    enlarge y limits=0.1,
    xlabel=$x$,
    ylabel=$y$,
    x=1cm, y=1cm,
    xtick=\empty,
    ytick=\empty
    ]
\addplot [domain=-.5:1.65] {sin(deg(x))};
\draw[blue,->] (axis cs:pi/6,0.5)--(axis cs:pi/6,0) node[anchor=north, rotate=-90, pos=1.5]{$long-label$};
\draw[blue,->] (axis cs:pi/2,1)--(axis cs:pi/2,0) node[anchor=north]{$s_2$};
\end{axis} 
\end{tikzpicture}
\end{document}

Bildbeschreibung hier eingeben

Antwort1

Verwenden Sie anchor=weststattdessen (ohne pos; Standard ist 1.0). Und verwenden Sie den Mathematikmodus nicht für Text (ich bin mir über Ihren tatsächlichen Anwendungsfall hier nicht sicher).

Die vollständige Erklärung: Wenn der rotateSchlüssel verwendet wird, rotieren die Anker des Knotens ( north, southusw.) mit (d. h. es handelt sich um eine lokale Koordinatentransformation). Daher liegt „Norden“ in Bezug auf das Hauptkoordinatensystem tatsächlich westinnerhalb des gedrehten Koordinatensystems des Knotens.

\documentclass[12pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
   scale=5,
   anchor=origin, 
   axis x line=middle,
   axis y line=middle,
   every axis x label/.style={at={(current axis.right of origin)},anchor=west},
   every axis y label/.style={at={(current axis.above origin)},anchor=south},
    enlarge x limits=0.05,
    enlarge y limits=0.1,
    xlabel=$x$,
    ylabel=$y$,
    x=1cm, y=1cm,
    xtick=\empty,
    ytick=\empty
    ]
\addplot [domain=-.5:1.65] {sin(deg(x))};
\draw[blue,->] (axis cs:pi/6,0.5)--(axis cs:pi/6,0) node[anchor=west, rotate=-90]{long-label};
\draw[blue,->] (axis cs:pi/2,1)--(axis cs:pi/2,0) node[anchor=north]{$s_2$};
\end{axis} 
\end{tikzpicture}
\end{document}

Bildbeschreibung hier eingeben

verwandte Informationen