# Using node or draw circle in tikz-3dplot

I am exploring the tikz-3dplot package for drawing objects in 3d and experienced a problem. I simply want to draw a circle and reference some of the points later, but I found there is a difference when using the draw command and using the node command:

\documentclass[tikz]{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}

\begin{document}
\tdplotsetmaincoords{70}{110}
\begin{tikzpicture}[tdplot_main_coords]
\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};
\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};

\coordinate (O) at (0,0,0);
\tdplotsetcoord{P}{1}{70}{40}

\draw[-stealth,color=blue] (O) -- (P);

\node[draw, circle, radius=0.2] (cir) at (P) {};

\draw (cir.south) -- (cir.north);

\end{tikzpicture}%
\end{document}


Why is the difference? I would like to use node as I can reference, for example, the south and north points for later use, probably projection. But using node doesn't provide the right shape (I want the red circle to be drawn with node so I can reference it). I don't understand why the node is not using the tdplot_main_coords coordinate system. Thanks.

• node almost always draws on the 2d canvas; it is not aware of the 3d coordinate system provided by tdplot_main_coords. If you want to refer to a particular point on a circle just hard-code the coordinate. – Symbol 1 Feb 23 at 4:43
• @Symbol1 The 3d library allows you to draw the node in any plane. – user121799 Feb 23 at 5:21
• @marmot I wonder how .south etc works in that case. – Symbol 1 Feb 23 at 5:27
• @Symbol1 You can see that in the lower part of my answer. .south is equivalent to .-90. Of course, this is a circle in the xy plane, so .south is the point with the smallest y value. – user121799 Feb 23 at 5:29

This is because you draw the circle by default in the xy-plane. You can draw it in the screen coordinates to "synchronize" it with the node.

\documentclass[tikz]{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}

\begin{document}
\tdplotsetmaincoords{70}{110}
\begin{tikzpicture}[tdplot_main_coords]
\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};
\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};

\coordinate (O) at (0,0,0);
\tdplotsetcoord{P}{1}{70}{40}

\draw[-stealth,color=blue] (O) -- (P);

\node[draw, circle, radius=0.2] (cir) at (P) {};

\draw (cir.south) -- (cir.north);

\end{tikzpicture}%
\end{document}


If you want instead the node been drawn in the xy plane, this can be done with the 3d library.

\documentclass[tikz]{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{3d}

\begin{document}
\tdplotsetmaincoords{70}{110}
\begin{tikzpicture}[tdplot_main_coords]
\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};
\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};

\coordinate (O) at (0,0,0);
\tdplotsetcoord{P}{1}{70}{40}

\draw[-stealth,color=blue] (O) -- (P);

\begin{scope}[canvas is xy plane at z=0,transform shape]
\node[draw, circle, radius=0.2] (cir) at (P) {};
\end{scope}

• Thanks, I tried \begin{scope}[canvas is xy plane at z=0,transform shape]as in your answer but it doesn't work for me, instead I need canvas is yx plane at z=0,transform shape and the north and south flip. I am using Texlive 2017, is that time to update? And I am wondering why the size of the circle drawn by node and draw are different? Thanks. – bingung Feb 23 at 11:01
• @bingung I just saw I missed the second part of your question. Nodes have inner sep, so you could do \node[draw, circle, minimum width=0.4cm,inner sep=0pt] (cir) at (P) {}; to get the same radius. See here for more details. – user121799 Feb 23 at 16:07