pgfplot 핀 길이

pgfplot 핀 길이

매뉴얼 의 다음 예를 고려하십시오 pgfplot.

\begin{tikzpicture}
  \tikzset{
    every pin/.style={fill=yellow!50!white,rectangle,rounded corners=3pt,font=\tiny},
    small dot/.style={fill=black,circle,scale=0.3}
  }
  \begin{axis}[
    clip=false,
    title=How \texttt{axis description cs} works
  ]
  \addplot {x};

  \node[small dot,pin=120:{$(0,0)$}]
  \node[small dot,pin=-30:{$(1,1)$}]
  \node[small dot,pin=-90:{$(1.03,0.5)$}]
  \node[small dot,pin=125:{$(0.5,0.5)$}]
  \end{axis}
\end{tikzpicture}

해당 코드는 다음 이미지를 제공합니다

위 코드로 생성된 이미지

바꾸고 싶은데 설명서에서 찾을 수 없었던 것은 핀 길이를 바꾸는 것입니다. 예를 들어 중앙에 있는 핀의 텍스트가 y축의 값 5에 더 가깝게 나타나도록 만들고 연결선 범위를 해당 지점까지 만듭니다. 내가 원하는 결과는 다음 그림에 나타납니다.

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

어떻게 든 가능합니까?

답변1

당신이 사용할 수있는 pin distance:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
  \tikzset{
    every pin/.style={fill=yellow!50!white,rectangle,rounded corners=3pt,font=\tiny},
    small dot/.style={fill=black,circle,scale=0.3}
  }
  \begin{axis}[
    clip=false,
    title=How \texttt{axis description cs} works
  ]
  \addplot {x};

  \node[small dot,pin=120:{$(0,0)$}] at (axis description cs:0,0) {};
  \node[small dot,pin=-30:{$(1,1)$}] at (axis description cs:1,1) {};
  \node[small dot,pin={[pin distance=2cm]125:{$(0.5,0.5)$}}] at (axis description cs:0.5,0.5) {};
  \end{axis}
\end{tikzpicture}

\end{document}

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

관련 정보