![pgfplot ピンの長さ](https://rvso.com/image/254729/pgfplot%20%E3%83%94%E3%83%B3%E3%81%AE%E9%95%B7%E3%81%95.png)
マニュアルの次の例を考えてみましょう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}