PGFPLOTS에서 회전된 라벨의 수평 이동

PGFPLOTS에서 회전된 라벨의 수평 이동

다음 코드에는 화살표 머리 중 하나에 긴 레이블이 있습니다. 라벨을 90도 회전한 다음 화살표 머리 바로 아래에 배치하고 싶습니다. 라벨을 수직으로 회전하고 이동시키는 rotate옵션과 옵션을 사용했습니다 . pos화살표 머리 바로 아래에 표시되도록 레이블을 수평으로 오른쪽으로 이동하려면 어떻게 해야 합니까?

\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키를 사용하면 노드의 앵커( north, south등이 키와 함께 회전합니다(즉, 로컬 좌표 변환입니다). 따라서 "북쪽"은 주 좌표계가 실제로 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}

여기에 이미지 설명을 입력하세요

관련 정보