我使用 tkz-graph 包制作了一个图形,并想使用 tikzducks 包制作图形的顶点。(具体来说,我想用彩色鸭子替换任意图形顶点的点)。这可能吗?
这是我的代码:
\begin{tikzpicture}
\renewcommand*{\VertexLineWidth}{2pt}
\GraphInit[vstyle=Welsh]
\Vertices[unit=3]{circle}{A,B,C,D,E,F,G}
\SetVertexNoLabel
\AddVertexColor{red}{B,F} \AddVertexColor{blue}{E,A}
\AddVertexColor{green}{C,G}\AddVertexColor{yellow}{D}
\Vertex[Node]{D}
\Edges(G,E,F,G,B,D,E,C,D,A,C,B,A)\Edges(B,E)
\end{tikzpicture}
答案1
当然,也许是这样:
\documentclass[border=10pt]{standalone}
\usepackage{tkz-graph}
\usetikzlibrary{ducks}
\newcommand*{\AddVertexDuckColor}[2]{%
\begingroup
\tikzset{VertexStyle/.append style = {duck = {duck/body=#1}}}
\foreach \v in {#2} { \Vertex[Node, NoLabel] {\v} }
\endgroup
}
\begin{document}
\begin{tikzpicture}
\GraphInit[vstyle=Welsh]
\tikzset{
duck/.style={
path picture={
\pic[scale=0.25, xshift=-1cm, yshift=-1cm, #1] {duck};
}
},
VertexStyle/.append style={
draw=none,
fill=none,
minimum size=0.6cm,
duck
}
}
\Vertices[unit=3]{circle}{A,B,C,D,E,F,G}
\SetVertexNoLabel
\AddVertexDuckColor{red}{B,F}
\AddVertexDuckColor{blue}{E,A}
\AddVertexDuckColor{green}{C,G}
\Vertex[Node]{D}
\AddVertexDuckColor{yellow}{D}
\Edges(G,E,F,G,B,D,E,C,D,A,C,B,A)
\Edges(B,E)
\end{tikzpicture}
\end{document}