我不明白为什么节点的样式不变。节点 6 的颜色不变,我该如何实现?似乎创建节点后样式就无法更改。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{ graphs, graphs.standard }
\usetikzlibrary{ calc }
\begin{document}
\begin{tikzpicture}
\graph [nodes={fill = blue}, empty nodes] {
subgraph I_n [clockwise, radius = 2cm, n = 6];
6 [fill = red];
7 [at = { ($(1) ! 0.5 ! (4)$) }, fill = red];
};
\end{tikzpicture}
\end{document}
答案1
这个问题的答案中描述了几种方法:TikZ 3.0:为子图中的特定节点着色。这里有一个可能的解决方案:
\documentclass{article}
% Adapted from https://tex.stackexchange.com/a/269274/
\usepackage{tikz}
\usetikzlibrary{ graphs, graphs.standard,backgrounds }
\usetikzlibrary{ calc }
\pgfdeclarelayer{foreground}
\pgfsetlayers{main,foreground}
\begin{document}
\begin{tikzpicture}
\graph [nodes={fill = blue}, empty nodes] {
subgraph I_n [clockwise, radius = 2cm, n = 6];
};
\begin{pgfonlayer}{foreground}
\node[fill = red] at (6) {};
\node[fill = red] at ($(1) ! 0.5 ! (4)$) {};
\end{pgfonlayer}
\end{tikzpicture}
\end{document}