我刚刚找到了pin
绘图选项,它看起来对我想要绘制的一些东西很有用。但是我该如何格式化它?我试过了,pin=[red]60:{Hey!}
但出现了错误Cannot parse this coordinate.
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning}
\begin{document}
\begin{tikzpicture}[node distance=2cm,>=latex, every node/.style={
font=\sffamily\scriptsize
},
circtext/.style={draw,circle,minimum size=8pt,inner sep=2pt},
dot/.style={draw,circle,fill=black,minimum size=0.6mm,inner sep=0pt}
]
{
\node[rectangle, fill=green!10!white!90!black, minimum width=6cm, minimum height=3cm] at (2,0){};
\node[circtext, fill=yellow](A) at (0,0) {A};
\node[circtext, fill=yellow, right=of A](B){B};
\draw[->] (A) -- node[dot, pos=0.5, pin=[red]60:{Hey!}](C){}(B);
}
\end{tikzpicture}
\end{document}
默认样式看起来像是一个灰色细箭头,我想将其更改为没有箭头的黑色细虚线。
更新:我知道如何向 pin 节点添加样式:
pin={[red]60:Hey!}]
但我不知道如何改变线条样式。
答案1
啊哈,明白了:
pin={[pin edge={edgestyles}, nodestyles]60:Hey!}]
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning}
\begin{document}
\begin{tikzpicture}[node distance=2cm,>=latex, every node/.style={
font=\sffamily\scriptsize
},
circtext/.style={draw,circle,minimum size=8pt,inner sep=2pt},
dot/.style={draw,circle,fill=black,minimum size=0.6mm,inner sep=0pt}
]
{
\node[rectangle, fill=green!10!white!90!black, minimum width=6cm, minimum height=3cm] at (2,0){};
\node[circtext, fill=yellow](A) at (0,0) {A};
\node[circtext, fill=yellow, right=of A](B){B};
\draw[->] (A) -- node[dot, pos=0.5, pin={[pin edge={black, dashed, -}, red]60:Hey!}](C){}(B);
}
\end{tikzpicture}
\end{document}