tikz 没有正确定位我的节点

tikz 没有正确定位我的节点

我正在使用以下代码:

\begin{tikzpicture}
\node[draw,
    circle,
    minimum size=1.0cm,
    fill=green
] (world_node) at (0,0){Scene};
\node[draw,
    circle,
    minimum size=1.0cm
] (anchor_node) at (3,0){Anchor Node};
\draw[-stealth] (world_node.east) -- (anchor_node.west) 
    node[near end,left]{};
\node[draw,
    circle,
    minimum size=1.0cm,
    fill=pink,
    below left= 0.1cm and 1cm of anchor_node
] (anchor_x_axis){\tiny x-axis};
\node[draw,
    circle,
    minimum size=1.0cm,
    fill=pink,
    below right= 0.25cm and  0.25cm of anchor_x_axis
] (anchor_x_axis_label){\tiny x-axis label};
\draw[-stealth] (anchor_node.south west) -- (anchor_x_axis.10) node[near end,left]{};
\draw[-stealth] (anchor_node.260) -- (anchor_x_axis_label.45) node[near end,left]{};
\node[draw,
    circle,
    minimum size=1.0cm,
    fill=white!90!blue,
    above left= 0.1cm and 1cm of anchor_node
] (anchor_y_axis){\tiny y-axis};
\node[draw,
    circle,
    minimum size=1.0cm,
    fill=white!90!blue,
    above right= 0.25cm and  0.25cm of anchor_y_axis
] (anchor_y_axis_label){\tiny y-axis label};
\draw[-stealth] (anchor_node.north west) -- (anchor_y_axis.345) node[near end,left]{};
\draw[-stealth] (anchor_node.100) -- (anchor_y_axis_label.310) node[near end,left]{};
\node[draw,
    circle,
    minimum size=1.0cm,
    fill=white!90!yellow,
    above right= 0.1cm and 1cm of anchor_node
] (anchor_z_axis){\tiny z-axis};
\node[draw,
    circle,
    minimum size=1.0cm,
    fill=white!90!yellow,
    right= of anchor_node
] (anchor_z_axis_label){\tiny z-axis label};
\draw[-stealth] (anchor_node.east) -- (anchor_z_axis_label.west) node[near end,left]{};
\draw[-stealth] (anchor_node.45) -- (anchor_z_axis.190) node[near end,left]{};
\node[draw,
    circle,
    minimum size=1.0cm,
    bottom= of anchor_z_axis_label
] (cloud_status){\tiny cloud status};
\end{tikzpicture}

在此处输入图片描述

我想要将带有标签“云状态”的节点放在带有标签“z 轴标签”的节点下方。但它只是快速回到我放置场景节点的 (0, 0)。

答案1

你的代码抛出了错误

! Package pgfkeys Error: I do not know the key '/tikz/bottom', to which you pas
sed 'of anchor_z_axis_label', and I am going to ignore it. Perhaps you misspell
ed it.

因为您使用了bottom=of anchor_z_axis_label而不是below=of anchor_z_axis_label来定位最终节点。

每当 Overleaf 中编译按钮旁边的红色框中出现数字时(如下面的屏幕截图所示),不要忽略它。阅读错误,找出问题所在,然后修复它。

在此处输入图片描述

答案2

大部分都是题外话,因为您的问题已经由@Torbjørn T. 的回答解决了。

画你的形象我会

  • 除了节点外,使用极坐标,使用它们可以避免节点放置的问题“云状态”,我会将其放置在“x 轴”和“z 轴标签”的交叉点处
  • 对于所有节点,使用相同大小的节点形状,
  • 启用节点中较长的文本可以分成两行

在我看来,这些变化使得图像看起来更具吸引力。

在此处输入图片描述

梅威瑟:

\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                positioning}

\begin{document}
    \begin{tikzpicture}[
arr/.style = {draw=gray, ultra thick, -{Stealth[scale=0.8]}},
  C/.style = {circle, draw, semithick,
              fill=#1, font=\small,
              text width=4.4em, inner sep=1pt, align=center},
  S/.style = {double, double distance=2pt},
                        ]
\node[C=white, font=\Large]   (r)             {Anchor Node};
% left side
\node[C=blue!15] (s1) at (120:4) {y-axis label};
\node[C=blue!15] (s2) at (150:4) {y-axis};
\node[C=green,S, font=\large] (s3) at (180:4) {Scene};
\node[C=pink!15] (s4) at (210:4) {x-axis};
\node[C=pink!15] (s5) at (240:4) {x-axis label};
% right side
\node[C=yellow!15] (s6) at (30:4)  {z-axis};
\node[C=yellow!15] (s7) at (0:4)   {z-axis label};
%
\node[C=white]   (c) at (s5 -| s7)   {cloud status};
%%%% arrows
    \foreach \i in {1,2,4,5,6,7}
\draw[arr]  (r)  -- (s\i);
\draw[arr, shorten <=1pt]  (s3) -- (r);
    \end{tikzpicture}
\end{document}

附录:看来,OP不是澄清自己的问题,而是写了一个答案,从中可以看出,节点`云也连接到根节点,并且它与其他卫星节点的定位方式相同:

\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}

\begin{document}
    \begin{tikzpicture}[
arr/.style = {draw=gray, ultra thick, -{Stealth[scale=0.8]}},
  C/.style = {circle, draw, semithick,
              fill=#1, font=\small,
              text width=4.4em, inner sep=1pt, align=center},
  S/.style = {double, double distance=2pt},
                        ]
\node[C=white,font=\Large]  (r)             {Anchor Node};
% left side
\node[C=blue!15] (s1) at (90:4)  {y-axis label};
\node[C=blue!15] (s2) at (135:4) {y-axis};
\node[C=green,font=\large,S] (s3) at (180:4) {Scene};
\node[C=pink!15] (s4) at (225:4) {x-axis};
\node[C=pink!15] (s5) at (270:4) {x-axis label};
% right side
\node[C=white]     (s6) at (315:4)  {cloud status};
\node[C=yellow!15] (s7) at (0:4)    {z-axis label};
\node[C=yellow!15] (s8) at (45:4)   {z-axis};
%%%% arrows
    \foreach \i in {1,2,4,5,...,8}
\draw[arr]  (r)  -- (s\i);
\draw[arr, shorten <=1pt]  (s3) -- (r);
    \end{tikzpicture}
\end{document}

在此处输入图片描述

答案3

谢谢你的回答。我在 Discord 上问了同样的问题,最后才在 Stack Overflow 上发帖。他们提供了一个更令人满意的答案:

\begin{tikzpicture}[every node/.style={draw, circle, minimum size=1cm, font=\tiny}]
\path node (anchor) {\normalsize Anchor node}
  +(180:3) node[fill=green] (scene) {\normalsize Scene}
  +(140:3) node[fill=white!90!blue] (y) {\(y\)-axis}
  +(100:3) node[fill=white!90!blue] (ylabel) {\(y\)-axis label}
  +(-140:3) node[fill=pink] (x) {\(x\)-axis}
  +(-100:3) node[fill=pink] (xlabel) {\(x\)-axis label}
  +(40:3) node[fill=white!90!yellow] (z) {\(z\)-axis}
  +(0:3) node[fill=white!90!yellow] (zlabel) {\(z\)-axis label}
  +(-40:3) node (cloud) {cloud status};
\draw[-stealth] (scene) -- (anchor);
\draw[-stealth] (anchor) -- (x);
\draw[-stealth] (anchor) -- (y);
\draw[-stealth] (anchor) -- (z);
\draw[-stealth] (anchor) -- (xlabel);
\draw[-stealth] (anchor) -- (ylabel);
\draw[-stealth] (anchor) -- (zlabel);
\draw[-stealth] (anchor) -- (cloud);
\end{tikzpicture}

此外,我意识到它在下面而不是底部(我一直在关注本教程下面正在使用)

相关内容