Skip to content

Commit dc4ecde

Browse files
authored
Fix Bloch docstrings and improve visualization of the sphere (#487)
1 parent 97bf074 commit dc4ecde

File tree

5 files changed

+179
-176
lines changed

5 files changed

+179
-176
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
- Introduce `Lanczos` solver for `spectrum`. ([#476])
1111
- Add Bloch-Redfield master equation solver. ([#473])
12-
- Implement Bloch Sphere rendering and align style with qutip. ([#472], [#480], [#485])
12+
- Implement Bloch Sphere rendering and align style with qutip. ([#472], [#480], [#485], [#487])
1313
- Add `Base.copy` method for `AbstractQuantumObject`. ([#486])
1414

1515
## [v0.31.1]
@@ -239,3 +239,4 @@ Release date: 2024-11-13
239239
[#480]: https://github.com/qutip/QuantumToolbox.jl/issues/480
240240
[#485]: https://github.com/qutip/QuantumToolbox.jl/issues/485
241241
[#486]: https://github.com/qutip/QuantumToolbox.jl/issues/486
242+
[#487]: https://github.com/qutip/QuantumToolbox.jl/issues/487

docs/src/users_guide/plotting_the_bloch_sphere.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ In [`QuantumToolbox`](https://qutip.org/QuantumToolbox.jl/), this can be done us
1717

1818
In [`QuantumToolbox`](https://qutip.org/QuantumToolbox.jl/), creating a [`Bloch`](@ref) sphere is accomplished by calling either:
1919

20+
!!! note "Import plotting libraries"
21+
Remember to import plotting libraries first. Here, we demonstrate the functionalities with [`CairoMakie.jl`](https://docs.makie.org/stable/explanations/backends/cairomakie.html).
22+
2023
```@example Bloch_sphere_rendering
2124
b = Bloch()
2225
```
@@ -163,19 +166,25 @@ fig
163166

164167
## [Configuring the Bloch sphere](@id doc:Configuring-the-Bloch-sphere)
165168

166-
At the end of the last section we saw that the colors and marker shapes of the data plotted on the Bloch sphere are automatically varied according to the number of points and vectors added. But what if you want a different choice of color, or you want your sphere to be purple with different axes labels? Well then you are in luck as the Bloch class has many attributes which one can control. Assuming `b = Bloch()`:
169+
At the end of the last section we saw that the colors and marker shapes of the data plotted on the Bloch sphere are automatically varied according to the number of points and vectors added. But what if you want a different choice of color, or you want your sphere to be purple with different axes labels? Well then you are in luck as the [`Bloch`](@ref) structure has many fields which one can control. Assuming `b = Bloch()`:
170+
171+
### Data storage
167172

168173
| **Field** | **Description** | **Default setting** |
169174
|:----------|:----------------|:--------------------|
170175
| `b.points` | Points to plot on the Bloch sphere (3D coordinates) | `Vector{Matrix{Float64}}()` (empty) |
171176
| `b.vectors` | Vectors to plot on the Bloch sphere | `Vector{Vector{Float64}}()` (empty) |
172-
| `b.lines` | Lines to draw on the sphere (points, style, properties) | `Vector{Tuple{Vector{Vector{Float64}},String}}()` (empty) |
177+
| `b.lines` | Lines to draw on the sphere with each line given as `([start_pt, end_pt], line_format)` | `Vector{Tuple{Vector{Vector{Float64}},String}}()` (empty) |
173178
| `b.arcs` | Arcs to draw on the sphere | `Vector{Vector{Vector{Float64}}}()` (empty) |
179+
180+
### Properties
181+
182+
| **Field** | **Description** | **Default setting** |
183+
|:----------|:----------------|:--------------------|
174184
| `b.font_color` | Color of axis labels and text | `"black"` |
175-
| `b.font_size` | Font size for labels | `15` |
176-
| `b.frame_alpha` | Transparency of the frame background | `0.1` |
177-
| `b.frame_color` | Background color of the frame | `"gray"` |
178-
| `b.frame_limit` | Axis limits for the 3D frame (symmetric around origin) | `1.2` |
185+
| `b.font_size` | Font size for labels | `20` |
186+
| `b.frame_alpha` | Transparency of the wire frame | `0.1` |
187+
| `b.frame_color` | Color of the wire frame | `"gray"` |
179188
| `b.point_default_color` | Default color cycle for points | `["blue", "red", "green", "#CC6600"]` |
180189
| `b.point_color` | List of colors for Bloch point markers to cycle through | `Union{Nothing,String}[]` |
181190
| `b.point_marker` | List of point marker shapes to cycle through | `[:circle, :rect, :diamond, :utriangle]` |
@@ -186,14 +195,14 @@ At the end of the last section we saw that the colors and marker shapes of the d
186195
| `b.sphere_alpha` | Transparency of sphere surface | `"#FFDDDD"` |
187196
| `b.vector_color` | Colors for vectors | `["green", "#CC6600", "blue", "red"]` |
188197
| `b.vector_width` | Width of vectors | `0.025` |
189-
| `b.vector_arrowsize` | Arrow size parameters as (head length, head width, stem width) | `[0.07, 0.08, 0.08]` |
198+
| `b.vector_arrowsize` | Scales the size of the arrow head. The first two elements scale the radius (in `x/y` direction) and the last one is the length of the cone. | `[0.07, 0.08, 0.08]` |
190199
| `b.view` | Azimuthal and elevation viewing angles in degrees | `[30, 30]` |
191200
| `b.xlabel` | Labels for x-axis | `[L"x", ""]` (``+x`` and ``-x``) |
192-
| `b.xlpos` | Positions of x-axis labels | `[1.0, -1.0]` |
201+
| `b.xlpos` | Positions of x-axis labels | `[1.2, -1.2]` |
193202
| `b.ylabel` | Labels for y-axis | `[L"y", ""]` (``+y`` and ``-y``) |
194-
| `b.ylpos` | Positions of y-axis labels | `[1.0, -1.0]` |
203+
| `b.ylpos` | Positions of y-axis labels | `[1.2, -1.2]` |
195204
| `b.zlabel` | Labels for z-axis | `[L"\|0\rangle", L"\|1\rangle]"` (``+z`` and ``-z``) |
196-
| `b.zlpos` | Positions of z-axis labels | `[1.0, -1.0]` |
205+
| `b.zlpos` | Positions of z-axis labels | `[1.2, -1.2]` |
197206

198207
These properties can also be accessed via the `print` command:
199208

0 commit comments

Comments
 (0)