2

I tried to draw planetary system consisting of Sun-Venus-Earth. My code is

\begin{tikzpicture}[scale=0.1]
%-> DEFINITIONS
%... sizes
\def\srad{10}
\def\erad{3}
\def\eorb{60}
\def\vrad{0.3}
\def\vorb{0.7*\eorb}

\begin{scope}[canvas is zx plane at y=0]
    \draw[very thick]
        (0,0) circle(\srad)
            node{Sun}
        (60:\vorb) circle(\vrad)
        (60:\eorb) circle(\erad)
        ;
    \draw[->, thick, dotted]
        (50:\vorb)
            node[below]{Venus}
            arc(50:120:\vorb)
        ;
    \draw[->, thick, dotted]
        (50:\eorb)
            node[below]{Earth}
            arc(50:120:\eorb)
        ;
\end{scope}
\end{tikzpicture}

Question: How to draw the circles on zx plane without being deformed, but keeping the arc exactly as the already are?

2

Of course. You only have to define the coordinates of the centers of these objects inside the canvas is zx plane at y=0 scope, and draw the circles around these centers outside.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{3d}
% fix wrong implementation of xy canvas https://tex.stackexchange.com/a/48776/121799
\makeatletter
\tikzoption{canvas is xy plane at z}[]{%
  \def\tikz@plane@origin{\pgfpointxyz{0}{0}{#1}}%
  \def\tikz@plane@x{\pgfpointxyz{1}{0}{#1}}%
  \def\tikz@plane@y{\pgfpointxyz{0}{1}{#1}}%
  \tikz@canvas@is@plane
}
\makeatother
\begin{document}
\begin{tikzpicture}[scale=0.1]
%-> DEFINITIONS
%... sizes
\def\srad{10}
\def\erad{3}
\def\eorb{60}
\def\vrad{0.3}
\def\vorb{0.7*\eorb}

\begin{scope}[canvas is zx plane at y=0]
    \path
        (0,0) coordinate (Sun)
        (60:\vorb) coordinate (Venus)
        (60:\eorb) coordinate (Earth)
        ;
    \draw[->, thick, dotted]
        (50:\vorb)
            node[below]{Venus}
            arc(50:120:\vorb)
        ;
    \draw[->, thick, dotted]
        (50:\eorb)
            node[below]{Earth}
            arc(50:120:\eorb)
        ;
\end{scope}
\draw[very thick]
    (Sun) circle(\srad)  node{Sun}
    (Venus) circle(\vrad)
    (Earth) circle(\erad);
\end{tikzpicture}
\end{document}

enter image description here

If you also want to change the view, I'd recommend loading tikz-3dplot.

5
  • Thank you, @marmot (allways you and I am becoming a fan)! I used the code and it works perfectly even without the \makeatletter arguments. Should I care with it?
    – Brasil
    Nov 13 '18 at 17:49
  • 1
    @Brasil Not for this MWE, but I started distributing the fix for the xy plane to make it less likely for others to get unnecessary headache. You are, at this point, only using the xy plane, so you do not need it. However, as soon as you add stuff in which you need the xy plane, you'll need it.
    – user121799
    Nov 13 '18 at 17:53
  • Good! I just asked because I separate the files for figures from my work file so that I can use the figure elsewhere. So, my new doubt: \makeatletter must be at the preamble, or can be at any other place (the tex file with the tizkpicture, for instance)?
    – Brasil
    Nov 13 '18 at 17:55
  • 1
    In this case I believe you can put it everywhere as this is just a (re)definition of a tikzoption. And as I said for the example you can drop it.
    – user121799
    Nov 13 '18 at 17:59
  • 1
    For the record: Jake's patch is now incorporated in v3.1 of TikZ. Jan 15 '19 at 19:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.