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}

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

関連情報