答案1
我回答这个问题主要是为了防止你添加手动旋转的椭圆。以下大部分内容取自这个答案最突出的附录是使用库在 xy 平面上绘制的椭圆3d
,这需要提供的修复这个答案。
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{3d}
% small fix for canvas is xy plane at z % 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}
\tdplotsetmaincoords{60}{130}
%
\pgfmathsetmacro{\rvec}{.8}
\pgfmathsetmacro{\thetavec}{30}
\pgfmathsetmacro{\phivec}{60}
%
\begin{tikzpicture}[scale=5,tdplot_main_coords,>=latex]
\coordinate (O) at (0,0,0);
\begin{scope}[canvas is xy plane at z=0]
\fill[gray,opacity=0.3] circle (0.3cm and 1cm);
\end{scope}
\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,->,densely dashed] (0,0,0) -- ({sin(-20)},{cos(-20)},0)
node[anchor=north west]{$y'$};
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};
\tdplotsetcoord{P}{\rvec}{\thetavec}{\phivec}
\draw[-stealth,color=red] (O) -- (P) node[above right] {$B$};
\draw[dotted,thick] (O) -- (Pxy) -- (P) -- (Pz);
\tdplotdrawarc{(O)}{0.2}{0}{\phivec}{anchor=north}{$\varphi$}
\tdplotdrawarc{(O)}{0.2}{90}{110}{anchor=165}{$\alpha$}
\tdplotsetthetaplanecoords{\phivec}
\tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{0.5}{0}%
{\thetavec}{anchor=south west}{$\theta$}
\end{tikzpicture}
\end{document}