# Demo 1:Bloch 球轨迹 > 第 1 章 量子计算基础 · [本章演示](index.md) · [代码演示总索引](../index.md) **可视化**:球面 6 个箭头 —— 6 个基准态的 ⟨X⟩,⟨Y⟩,⟨Z⟩ 测得 Bloch 矢量画在单位球上 **对应教程**:[第 1 章 量子计算基础 中相关小节](https://tutorial.chenzhaoyun.com/quantum-tutorial/ch01-basics/) · 依赖安装:`pip install "unified-quantum[visualization,simulation]"` ## 实现要点 对 |0⟩、|1⟩、|+⟩、|-⟩、|+i⟩、|-i⟩ 六个基态分别在 X/Y/Z 基上做 2000 次测量, 反推出 Bloch 矢量 (⟨X⟩, ⟨Y⟩, ⟨Z⟩),在单位球面上画散点。 ## 完整源码 ```{literalinclude} 01_bloch_sphere.py :language: python :linenos: :caption: demos/ch01-basics/01_bloch_sphere.py ``` ## 运行结果 ![Demo 1:Bloch 球轨迹](01_bloch_sphere.png) ## 运行方式 ```bash # 仓库根目录执行;输出 PNG 到 demos/ch01-basics/01_bloch_sphere.png,关键统计到 stdout .venv/bin/python3 demos/ch01-basics/01_bloch_sphere.py ``` --- [← 本章演示](index.md) · [↑ 代码演示总索引](../index.md) · [⌂ 教程门户](https://tutorial.chenzhaoyun.com/)