在 TikZ 中生成此 Bloch 球

在 TikZ 中生成此 Bloch 球

我使用以下方式制作了这些图像Mathematica

布洛赫球

我想使用 TikZ 来重现它(轴标签范围从 0 到 1)。困难在于获得相似的配色方案,使图像具有相同的 3D 感。我设法获得了一个基本的 MWE,可以恢复左侧图像:

平均能量损失

\documentclass[tikz]{standalone}
\usepackage{pgfplots}           
\usetikzlibrary{shapes,backgrounds,fit,decorations.pathreplacing,chains,snakes,angles,quotes}  %TikZ libraries
\usetikzlibrary{arrows.meta, arrows, positioning}

\begin{document}

\begin{tikzpicture}[line cap=round, line join=round]
\draw[line width=5pt](0,0) circle (8);
\draw [line width=5pt,rotate around={0.:(0.,0.)},dash pattern=on 10pt off 10pt] (0,0) ellipse (8 and 3);
\draw[line width=5pt] [-{Latex[length=8mm]}] (0,0) -- (0,8);
\draw [line width=5pt] [-{Latex[length=8mm]}]  (0,0) -- (-3,-2.75);
\draw [line width=5pt] [-{Latex[length=8mm]}] (0,0) -- (8,0);

\node[circle,shading=ball,minimum width=8cm,opacity=0.4] (ball) at (0,0) {};

\end{tikzpicture}
\end{document}

生成:

左图

这感觉离期望的输出还很远。有什么建议吗?

答案1

我并不是说这与您从 Mathematica 获得的结果完全匹配,但以下内容可以说明您只需付出很少的努力就能做什么。

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{arrows.meta, shadings}

\begin{document}
\begin{tikzpicture}[line cap=round, line join=round]
\draw[line width=5pt,] (0,0) circle (8);
\draw[line width=5pt,rotate around={0.:(0.,0.)},dash pattern=on 10pt off 10pt] (0,0) ellipse (8 and 3);
\draw[line width=5pt] [-{Latex[length=8mm]}] (0,0) -- (0,8);
\draw[line width=5pt] [-{Latex[length=8mm]}]  (0,0) -- (-3,-2.75);
\draw[line width=5pt] [-{Latex[length=8mm]}] (0,0) -- (8,0);

\fill[white,opacity=0.4] (0,0) circle (3);

\shade[right color=orange,middle color=red,left color=blue,opacity=0.3,shading angle=-110] 
 (0,0) circle (3);
\shade[ball color=orange,opacity=0.2] 
 (0,0) circle (3);
\begin{scope}[xshift=17cm]
 \draw[line width=5pt,] (0,0) circle (8);
 \draw[line width=5pt,rotate around={0.:(0.,0.)},dash pattern=on 10pt off 10pt] (0,0) ellipse (8 and 3);
 \draw[line width=5pt] [-{Latex[length=8mm]}] (0,0) -- (0,8);
 \draw[line width=5pt] [-{Latex[length=8mm]}]  (0,0) -- (-3,-2.75);
 \draw[line width=5pt] [-{Latex[length=8mm]}] (0,0) -- (8,0);
 \fill[white,opacity=0.4] (0,0) circle (2 and 6);
 \shade[right color=orange,middle color=red,left color=blue,opacity=0.3,shading angle=-110] 
  (0,0) circle (2 and 6);
 \shade[ball color=orange,opacity=0.2] 
  (0,0) circle (2 and 6);
\end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

使用淡入淡出可能会实现更加令人印象深刻的效果。

相关内容