星形图 x 和 y 坐标问题

星形图 x 和 y 坐标问题

我可以\grComplete在 tikzpicture 中放置多个 s,并将它们很好地隔开。但是当我尝试对 执行相同操作时\grStar,它不起作用。我做错了什么?这是一个最小示例。

\documentclass[a4paper]{article}

\usepackage{tikz}
\usepackage{tkz-berge}

\begin{document}

These complete graphs are spread out nicely.

\begin{tikzpicture}
  \GraphInit[vstyle=Simple];
  \node[align=center] at (0,0.5) {$K_1$};
  \grComplete[x=0,y=0,RA=0]{1};
  \node[align=center] at (3,0.5) {$K_2$};
  \grComplete[x=3,y=0,RA=1]{2};
  \node[align=center] at (6,1.5) {$K_3$};
  \grComplete[x=6,y=0,RA=1]{3};
  \node[align=center] at (9,1.5) {$K_4$};
  \grComplete[x=9,y=0,RA=1]{4};
  \node[align=center] at (12,1.5) {$K_5$};
  \grComplete[x=12,y=0,RA=1]{5};
\end{tikzpicture}

This is supposed to be 5 star graphs, but they are not spread out.

\begin{tikzpicture}
  \GraphInit[vstyle=Simple];
  \node[align=center] at (0,0.5) {$S_1$};
  \grStar[x=0,y=0,RA=1]{2};
  \node[align=center] at (3,0.5) {$S_2$};
  \grStar[x=3,y=0,RA=1]{4};
  \node[align=center] at (6,1.5) {$S_3$};
  \grStar[x=6,y=0,RA=1]{4};
  \node[align=center] at (9,1.5) {$S_4$};
  \grStar[x=9,y=0,RA=1]{5};
  \node[align=center] at (12,1.5) {$S_5$};
  \grStar[x=12,y=0,RA=1]{6};
\end{tikzpicture}

\end{document}

结果如下: 乳胶输出

答案1

选项xy似乎只适用于某些没有中心节点的图形。至少对于星形图,使用xy显然不会移动中心节点。该包的文档在某些情况下使用范围来移动图形。因此,我建议您也至少对星形图遵循这种做法:

\documentclass[a4paper]{article}

\usepackage{tikz}
\usepackage{tkz-berge}

\begin{document}

These complete graphs are spread out nicely.

\begin{tikzpicture}
  \GraphInit[vstyle=Simple];
  \node at (0,0.5) {$K_1$};
  \grComplete[x=0,RA=0]{1};
  \node at (3,0.5) {$K_2$};
  \grComplete[x=3,RA=1]{2};
  \node at (6,1.5) {$K_3$};
  \grComplete[x=6,RA=1]{3};
  \node at (9,1.5) {$K_4$};
  \grComplete[x=9,RA=1]{4};
  \node at (12,1.5) {$K_5$};
  \grComplete[x=12,RA=1]{5};
\end{tikzpicture}

This is supposed to be 5 star graphs, and they are now also spread out nicely.

\begin{tikzpicture}
  \GraphInit[vstyle=Simple];
  \node at (0,0.5) {$S_1$};
  \begin{scope}[xshift=0cm]
    \grStar[RA=0]{2};
  \end{scope}
  \node at (3,0.5) {$S_2$};
  \begin{scope}[xshift=3cm]
    \grStar[RA=1]{3};
  \end{scope}
  \node at (6,1.5) {$S_3$};
  \begin{scope}[xshift=6cm]
    \grStar[RA=1]{4};
  \end{scope}
  \node at (9,1.5) {$S_4$};
  \begin{scope}[xshift=9cm]
    \grStar[RA=1]{5};
  \end{scope}
  \node at (12,1.5) {$S_5$};
  \begin{scope}[xshift=12cm]
    \grStar[RA=1]{6};
  \end{scope}
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容