PGFPLOTS で回転したラベルの水平移動

PGFPLOTS で回転したラベルの水平移動

次のコードでは、矢印の先端の 1 つに長いラベルがあります。ラベルを 90 度回転して、矢印の先端の真下に配置したいと思います。オプションrotateposオプションを使用して、ラベルを回転および垂直方向に移動しました。ラベルを水平方向に右に移動して、矢印の先端の真下に表示されるようにするにはどうすればよいでしょうか。

\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}

ここに画像の説明を入力してください

答え1

代わりにを使用してくださいanchor=west( なしpos、デフォルトは1.0)。また、テキストには数式モードを使用しないでください (ここでの実際の使用例はわかりません)。

完全な説明:rotateキーを使用すると、ノードのアンカー ( northsouthなど) がそれとともに回転します (つまり、ローカル座標変換です)。したがって、メイン座標系に対する「北」は、実際にはwestノードの回転された座標系内にあります。

\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}

ここに画像の説明を入力してください

関連情報