将圆圈改为“-stealth”

将圆圈改为“-stealth”

我从 pgfplots 中举了一个例子

% Preamble: \pgfplotsset{width=7cm,compat=1.3}
% [See the TikZ manual if you’d like to learn about nodes and pins]
 \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=-90:{$(1.03,0.5)$}] at (axis description cs:1.03,0.5) {};
  \node[small dot,pin=125:{$(0.5,0.5)$}] at (axis description cs:0.5,0.5) {};
 \end{axis}
\end{tikzpicture}

在此处输入图片描述

我想放置一个箭头(-stealth')而不是圆圈,并且能够控制其厚度。

答案1

TikZ 手册的部分The pin option解释了如何控制pinpin edge样式。这里有一些带有代码的示例。如果您不想dots在标记点上使用,请small dot从每个节点中删除选项。

\documentclass{standalone}
\usepackage{pgfplots}
\usetikzlibrary{arrows}
\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},
      every pin edge/.style={<-,>=stealth'},
      mypinedgestyle/.style={<-,>=stealth',dashed,green, very thick}
  }
  \begin{axis}[
              clip=false,
              title=How \texttt{axis description cs} works
  ]
  \addplot {x};
  \node[small dot,pin={[pin edge={<-,>=stealth',red,very thick}]120:{$(0,0)$}}] at (axis description cs:0,0) {};
  \node[small dot,pin={[pin edge={mypinedgestyle}]-30:{$(1,1)$}}] at (axis description cs:1,1) {};
  \node[small dot,pin=-90:{$(1.03,0.5)$}] at (axis description cs:1.03,0.5) {};
  \node[small dot,pin=125:{$(0.5,0.5)$}] at (axis description cs:0.5,0.5) {};
 \end{axis}
\end{tikzpicture}
\end{document}

结果是:

在此处输入图片描述

答案2

使用该pin选项可能并不理想。因为它会将节点放在您想要箭头的位置。使用装饰或自定义节点形状可能可行,但在我看来这不是最简单的解决方案。最简单的解决方案是从您想要指向的坐标到包含信息的节点创建一条路径。看起来就像这样:

\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,-stealth,scale=0.3}
  }
  \begin{axis}[
              clip=false,
              title=How \texttt{axis description cs} works
  ]
  \addplot {x};
  \draw[stealth-, very thin] (axis description cs:0,0) -- ++(140:1cm) node[every pin]{$(0,0)$};
  \draw[stealth-, very thin] (axis description cs:1,1) -- ++(-40:1cm) node[every pin]{$(1,1)$};
  \draw[stealth-, very thin] (axis description cs:1.03,0.5) -- ++(-90:1cm) node[every pin]{$(1.03,0.5)$};
  \draw[stealth-, very thin] (axis description cs:0.5,0.5) -- ++(125:1cm) node[every pin]{$(0.5,0.5)$};
 \end{axis}
\end{tikzpicture}
\end{document}

得到如下图片:

带箭头的图像

相关内容