![pgfplot 腳位長度](https://rvso.com/image/254729/pgfplot%20%E8%85%B3%E4%BD%8D%E9%95%B7%E5%BA%A6.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}