我正在尝试旋转 K4 的绘图,使其形成正方形而不是菱形。我正在使用环境scope
,但当我将transform shape
其作为一个选项时,我发现标签也会旋转。但是,删除该选项会导致形状不旋转。我已附上我编写的 latex 代码以及编译后的结果。我在旋转标准图看起来这样做是正确的,但我无法重现它。任何帮助都将不胜感激。
\begin{tikzpicture}[node distance=2.5cm, every node/.style={circle, draw}]
\graph[clockwise, radius=3cm] {subgraph C_n [name=A,V={A,B,C,D}] };
\begin{scope}[rotate=45, transform shape]
\graph[clockwise, radius=1.25cm] {subgraph K_n [name=B,V={E,F,G,H}] };
\end{scope}
\node[draw=none, rectangle, above=0.8cm] at (current bounding box.north) {$L(G)$};
\draw (A A) -- (B E);
\draw (A A) -- (B F);
\draw (A B) -- (B F);
\draw (A B) -- (B G);
\draw (A C) -- (B G);
\draw (A C) -- (B H);
\draw (A D) -- (B H);
\draw (A D) -- (B E);
\end{tikzpicture}
答案1
欢迎!您不应该旋转子图,而是更改其phase
。 的默认值为phase
90,您想旋转 45,因此您需要135
。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{graphs}
\usetikzlibrary{graphs.standard}
\begin{document}
\begin{tikzpicture}[node distance=2.5cm, every node/.style={circle, draw}]
\graph[clockwise, radius=3cm] {subgraph C_n [name=A,V={A,B,C,D}] };
\graph[clockwise, radius=1.25cm,phase=135] {
subgraph K_n [name=B,V={E,F,G,H}] };
\node[draw=none, rectangle, above=0.8cm] at (current bounding box.north) {$L(G)$};
\draw (A A) -- (B E);
\draw (A A) -- (B F);
\draw (A B) -- (B F);
\draw (A B) -- (B G);
\draw (A C) -- (B G);
\draw (A C) -- (B H);
\draw (A D) -- (B H);
\draw (A D) -- (B E);
\end{tikzpicture}
\end{document}
顺便说一句,人们也可以相当简化边缘的构造,但这不是这里的主题。