如何修改此 tikz 代码片段中任意节点的颜色?
\begin{tikzpicture}[sibling distance=3em, every node/.style = { rounded corners, draw,
align=right, top color=white, bottom color=blue!30}]]
\node {000}
child { node {000}}
child { node {100}}
child { node {010}}
child { node {001}
child { node {000}
child { node {000}}
child { node {100}}
child { node {010}}
child { node {001}}
child { node {110}}
child { node {011}}
child { node {101}}
child { node {111}} }
child { node {100}}
child { node {010}}
child { node {001}}
child { node {101}}
child { node {011}}
child { node {110}}
child { node {111}} }
child { node {101}}
child { node {011}}
child { node {110}}
child { node {111}};
\end{tikzpicture}
答案1
我不太明白你的意思。不过,我为你做了这个小修改。
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\tikzset{
stdNode/.style={rounded corners, draw, align=right},
greenRed/.style={stdNode, top color=green, bottom color=red},
blueRed/.style={stdNode, top color=blue, bottom color=red}
}
\begin{tikzpicture}[sibling distance=3em, every node/.style={rounded corners, draw, align=right, top color=white, bottom color=blue!30}]]
\node {000}
child { node[red] {000}}
child { node[top color=green,bottom color=red!30] {100}}
child { node[greenRed] {010}}
child { node[blueRed] {001}
child { node {000}
child { node {000}}
child { node {100}}
child { node {010}}
child { node {001}}
child { node {110}}
child { node {011}}
child { node {101}}
child { node {111}} }
child { node {100}}
child { node {010}}
child { node {001}}
child { node {101}}
child { node {011}}
child { node {110}}
child { node {111}} }
child { node {101}}
child { node {011}}
child { node {110}}
child { node {111}};
\end{tikzpicture}
\end{document}
我强烈推荐手册.pdf在https://ctan.org/pkg/pgf。
仅仅因为一个人可以选择这些奇怪的颜色并不意味着他应该这样做。