![根节点和子节点之间的思维导图颜色阴影未使用正确的颜色](https://linux22.com/image/430475/%E6%A0%B9%E8%8A%82%E7%82%B9%E5%92%8C%E5%AD%90%E8%8A%82%E7%82%B9%E4%B9%8B%E9%97%B4%E7%9A%84%E6%80%9D%E7%BB%B4%E5%AF%BC%E5%9B%BE%E9%A2%9C%E8%89%B2%E9%98%B4%E5%BD%B1%E6%9C%AA%E4%BD%BF%E7%94%A8%E6%AD%A3%E7%A1%AE%E7%9A%84%E9%A2%9C%E8%89%B2.png)
我正在尝试在 中创建思维导图tikz
,但当我将根节点的颜色定义为不同于“默认颜色”时,出现了问题。主要是,根节点和其子节点之间的连接没有使用正确的颜色,如下图所示。我该如何解决这个问题?
这是 MWE:
\documentclass[border = 3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{mindmap}
\pagestyle{empty} % Clear page
\begin{document}
\begin{tikzpicture}[% Tikz picture options and styles on midmap
mindmap,
every node/.style={concept, execute at begin node=\hskip0pt},
root concept/.append style={
concept color=gray,text width = 3cm},
concept color = yellow, % Default node color
text = white, % Default text color
grow cyclic,
level 1/.append style={level distance=6cm,sibling angle=60},
level 2/.append style={level distance=3cm,sibling angle=90},
level 3/.append style={level distance=3cm,sibling angle=90},
]
\node[root concept]{Hello!}
child[concept color=red] { node {This is a red node}
}
child [concept color=blue]{ node{This is a blue node}
child[concept color=orange]{node{This is a orange node}}
child[concept color=green]{node{This is a green node}}
};
\end{tikzpicture}
\end{document}
可能与这个问题有关,但我发现xcolor
包中的某些颜色也有这种奇怪的行为。例如,考虑以下使用青色的图像:
回答相应的代码:
\documentclass[border = 3mm]{standalone}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{mindmap}
\pagestyle{empty} % Clear page
\begin{document}
\begin{tikzpicture}[% Tikz picture options and styles on midmap
mindmap,
every node/.style={concept, execute at begin node=\hskip0pt},
root concept/.append style={
concept color=gray,text width = 3cm},
concept color = yellow, % Default node color
text = white, % Default text color
grow cyclic,
level 1/.append style={level distance=6cm,sibling angle=60},
level 2/.append style={level distance=3cm,sibling angle=90},
level 3/.append style={level distance=3cm,sibling angle=90},
]
\clip (0,-1) rectangle ++(8,7);
\node[root concept]{Hello!}
child[concept color=red] { node {This is a red node}
}
child [concept color=cyan]{ node{This is a cyan node}
child[concept color=orange]{node{This is a orange node}}
child[concept color=green]{node{This is a green node}}
};
\end{tikzpicture}
\end{document}
答案1
像这样 ?
\documentclass[border = 3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{mindmap}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[
mindmap,
every node/.style={concept, execute at begin node=\hskip0pt},
root concept/.append style={concept color=gray, text width=3cm},
concept color=yellow, % Default node color
text=white, % Default text color
grow cyclic,
level 1/.append style={level distance=6cm, sibling angle=60},
level 2/.append style={level distance=3cm, sibling angle=45},
level 3/.append style={level distance=3cm, sibling angle=45},
]
\node[root concept] (root) {Hello!} % Root node
child [concept color=red] { node (red) {This is a red node} }
child [concept color=blue] { node (blue) {This is a blue node}
child [concept color=orange] { node (orange) {This is an orange node} }
child [concept color=green] { node (green) {This is a green node} }
};
% you add manually the connections with the right colors
\path (root) to [circle connection bar switch color=from (gray) to (red)] (red);
\path (root) to [circle connection bar switch color=from (gray) to (blue)] (blue);
\path (blue) to [circle connection bar switch color=from (blue) to (orange)] (orange);
\path (blue) to [circle connection bar switch color=from (blue) to (green)] (green);
\end{tikzpicture}
\end{document}