You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/users_guide/plotting_the_bloch_sphere.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,9 @@ In [`QuantumToolbox`](https://qutip.org/QuantumToolbox.jl/), this can be done us
17
17
18
18
In [`QuantumToolbox`](https://qutip.org/QuantumToolbox.jl/), creating a [`Bloch`](@ref) sphere is accomplished by calling either:
19
19
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
+
20
23
```@example Bloch_sphere_rendering
21
24
b = Bloch()
22
25
```
@@ -172,7 +175,7 @@ At the end of the last section we saw that the colors and marker shapes of the d
172
175
|`b.lines`| Lines to draw on the sphere (points, style, properties) |`Vector{Tuple{Vector{Vector{Float64}},String}}()` (empty) |
173
176
|`b.arcs`| Arcs to draw on the sphere |`Vector{Vector{Vector{Float64}}}()` (empty) |
174
177
|`b.font_color`| Color of axis labels and text |`"black"`|
175
-
|`b.font_size`| Font size for labels |`15`|
178
+
|`b.font_size`| Font size for labels |`20`|
176
179
|`b.frame_alpha`| Transparency of the frame background |`0.1`|
177
180
|`b.frame_color`| Background color of the frame |`"gray"`|
178
181
|`b.frame_limit`| Axis limits for the 3D frame (symmetric around origin) |`1.2`|
@@ -339,10 +337,7 @@ Render the Bloch sphere visualization from the given [`Bloch`](@ref) object `b`.
339
337
# Arguments
340
338
341
339
- `b::Bloch`: The Bloch sphere object containing states, vectors, and settings to visualize.
342
-
- `location`: Specifies where to display or save the rendered figure.
343
-
- If `nothing` (default), the figure is displayed interactively.
344
-
- If a file path (String), the figure is saved to the specified location.
345
-
- Other values depend on backend support.
340
+
- `location::Union{GridPosition,Nothing}`: The location of the plot in the layout. If `nothing`, the plot is created in a new figure. Default is `nothing`.
346
341
347
342
# Returns
348
343
@@ -351,13 +346,14 @@ Render the Bloch sphere visualization from the given [`Bloch`](@ref) object `b`.
351
346
function QuantumToolbox.render(b::Bloch; location =nothing)
352
347
fig, lscene =_setup_bloch_plot!(b, location)
353
348
_draw_bloch_sphere!(b, lscene)
354
-
_draw_reference_circles!(b, lscene)
355
-
_draw_axes!(b, lscene)
349
+
_add_labels!(b, lscene)
350
+
351
+
# plot data fields in Bloch
356
352
_plot_points!(b, lscene)
357
353
_plot_lines!(b, lscene)
358
354
_plot_arcs!(b, lscene)
359
355
_plot_vectors!(b, lscene)
360
-
_add_labels!(b, lscene)
356
+
361
357
return fig, lscene
362
358
end
363
359
@@ -383,15 +379,15 @@ function _setup_bloch_plot!(b::Bloch, location)
383
379
cam3d!(lscene.scene, center =false)
384
380
cam =cameracontrols(lscene)
385
381
cam.fov[] =12# Set field of view to 12 degrees
386
-
dist =12# Set distance from the camera to the Bloch sphere
382
+
dist =12# Set distance from the camera to the Bloch sphere
@@ -515,10 +515,7 @@ Render the Bloch sphere visualization from the given [`Bloch`](@ref) object `b`.
515
515
# Arguments
516
516
517
517
- `b::Bloch`: The Bloch sphere object containing states, vectors, and settings to visualize.
518
-
- `location`: Specifies where to display or save the rendered figure.
519
-
- If `nothing` (default), the figure is displayed interactively.
520
-
- If a file path (String), the figure is saved to the specified location.
521
-
- Other values depend on backend support.
518
+
- `location::Union{GridPosition,Nothing}`: The location of the plot in the layout. If `nothing`, the plot is created in a new figure. Default is `nothing`.
0 commit comments