I have this figure in spherical coordinates taken from here. I would like to use this figure to illustrate unit vectors at the point P. I have not been able to adapt the figures given on various posts. I manged to run the asymptote code here but in pdf format it comes compressed such that it is unreadable. I would appreciate if someone can add me some code in tikz so that I can draw a circle through P, with vectors in the three directions, east, north and zenith. I reproduce the code from the first site quoted above (appreciation and thanks @jubobs)

Yes the code by jubobs is half of what I want. What I want added to this are three unit vectors in the direction of the coordinate direction, i.e. at P we probably would have a circle running from north pole to south pole, and through P a vector in z-direction, a vector in $\phi$ direction and a vector in $\theta$ direction.

Please note that I am only adding a small addition to this post. The addition is explained in the last paragraph above.

The code supplied by mammot does exactly what I was looking for, my real appreciation for spending time and effort mammot. When I incorporate the code I get this. I had tried to turn the vector in the positive x-direction (opposite to what is the figure) no success so far. Seconddly I would appreciate adding a circle from north pole to south pole through P. Sorry for being too demanding, but the work is done. This is what I wanted and its fine. Once more my appreciation.



\coordinate (O) at (0,0,0);
\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$};
\draw[-stealth,color=red] (O) -- (P) node[above right] {$P$};

\draw[dashed, color=red] (P) -- (Pxy);
{\thetavec}{anchor=south west}{$\theta$}
\tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{0.5}{0} {\thetavec}
{anchor=south west}{$\theta$} \coordinate (Shift) at (P);
\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'$};
  • When you're saying that the asymptote code is compressed, do you mean that the image is too small? If so, have you tried playing with size and/or size3, e.g. by adding size(200); size3(200); to the asymptote code?
    – user121799
    Jan 2, 2018 at 22:39
  • Thanks @marmot I will give feedback after I play around with size. Lst time I tried i was getting nowhere. Jan 2, 2018 at 22:48
  • Does adding \tdplotsetthetaplanecoords{\phivec} \tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{0.5}{0}% {\thetavec}{anchor=south west}{$\theta$} \coordinate (Shift) at (P); \tdplotsetrotatedcoords{-\phivec}{-\thetavec}{\phivec} \tdplotsetrotatedcoordsorigin{(Shift)} \begin{scope}[tdplot_rotated_coords,scale=0.4,blue] \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'$}; \end{scope} to your code come close to a solution?
    – user121799
    Jan 2, 2018 at 23:14
  • Thanks @marmot, firstly my apologies for misspelling your name in the edit. You have solved my problem completely, please see the edit. Since this is done, I can as well forget the asymptote code. Thanks Jan 3, 2018 at 5:53
  • @Zarko I don't think this question is a duplicate, please see the edit by Zilore Mumba and my above comment, which I added because I could not post an answer.
    – user121799
    Jan 3, 2018 at 12:36


Browse other questions tagged or ask your own question.