tikz 图的各个顶点/节点的不同颜色和自定义

tikz 图的各个顶点/节点的不同颜色和自定义

所以我画的图是这样的

\documentclass{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
            \tikzset{Bullet/.style={fill=black,draw,color=black,circle,minimum size=3pt,scale=0.75}}
            \node[Bullet,label=left :{$u_1$}] (u1) at (0,2){};
            \node[Bullet,label=above:{$u_2$}] (u2) at (1,3){};
            \node[Bullet,label=right:{$u_3$}] (u3) at (2,2){};
            \node[Bullet,label=right:{$u_4$}] (u4) at (2,0){};
            \node[Bullet,label=left :{$u_5$}] (u5) at (0,0){};
            \draw[thick] (u1)--(u4)--(u5)--(u3)--(u2)--(u1);
\end{tikzpicture}

\end{document}

我想为每个节点/顶点设置单独的颜色。我可以这样做,但似乎有点笨拙。

\documentclass{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
            \tikzset{Bullet/.style={fill=black,draw,color=red,circle,minimum size=3pt,scale=0.75}}
            \node[Bullet,label=left :{$u_1$}] (u1) at (0,2){};
            \tikzset{Bullet/.style={fill=black,draw,color=orange,circle,minimum size=3pt,scale=0.75}}
            \node[Bullet,label=above:{$u_2$}] (u2) at (1,3){};
            \tikzset{Bullet/.style={fill=black,draw,color=yellow,circle,minimum size=3pt,scale=0.75}}
            \node[Bullet,label=right:{$u_3$}] (u3) at (2,2){};
            \tikzset{Bullet/.style={fill=black,draw,color=green,circle,minimum size=3pt,scale=0.75}}
            \node[Bullet,label=right:{$u_4$}] (u4) at (2,0){};
            \tikzset{Bullet/.style={fill=black,draw,color=blue,circle,minimum size=3pt,scale=0.75}}
            \node[Bullet,label=left :{$u_5$}] (u5) at (0,0){};
            \draw[thick] (u1)--(u4)--(u5)--(u3)--(u2)--(u1);
\end{tikzpicture}

\end{document}

我真正想要的是让它看起来像这样,以突出同构:

在此处输入图片描述 在此处输入图片描述

答案1

我不知道你重新提出这个问题的目的是什么。链接的问题(或 Kpym 的评论)确实确切地你想要得到什么。

\documentclass{standalone}
\usepackage{tikz}
\tikzset{Bullet/.style={fill=black,draw,color=#1,circle,minimum size=3pt,scale=0.75}}
\begin{document}
\begin{tikzpicture}
    \node[Bullet=red,label=left :{$u_1$}] (u1) at (0,2){};
    \node[Bullet=orange,label=above:{$u_2$}] (u2) at (1,3){};
    \node[Bullet=yellow,label=right:{$u_3$}] (u3) at (2,2){};
    \node[Bullet=green,label=right:{$u_4$}] (u4) at (2,0){};
    \node[Bullet=blue,label=left :{$u_5$}] (u5) at (0,0){};
    \draw[thick] (u1)--(u4)--(u5)--(u3)--(u2)--(u1);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容