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
+25-25Lines changed: 25 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,8 +24,8 @@ b = Bloch()
24
24
which will load an instance of [`Bloch`](@ref). Before getting into the details of these objects, we can simply plot the blank [`Bloch`](@ref) sphere associated with these instances via:
25
25
26
26
```@example Bloch_sphere_rendering
27
-
fig, _ = render(b)
28
-
fig
27
+
scene = render(b)
28
+
scene
29
29
```
30
30
31
31
See the [API documentation for Bloch sphere](@ref doc-API:Bloch-Sphere) for a full list of other available functions.
@@ -37,8 +37,8 @@ As an example, we can add a single data point via [`add_points!`](@ref):
37
37
```@example Bloch_sphere_rendering
38
38
pnt = [1 / sqrt(3), 1 / sqrt(3), 1 / sqrt(3)]
39
39
add_points!(b, pnt)
40
-
fig, _ = render(b)
41
-
fig
40
+
scene = render(b)
41
+
scene
42
42
```
43
43
44
44
## Add a single vector
@@ -48,8 +48,8 @@ Add a single vector via [`add_vectors!`](@ref):
48
48
```@example Bloch_sphere_rendering
49
49
vec = [0, 1, 0]
50
50
add_vectors!(b, vec)
51
-
fig, _ = render(b)
52
-
fig
51
+
scene = render(b)
52
+
scene
53
53
```
54
54
55
55
## Add a single quantum state
@@ -59,8 +59,8 @@ Add another vector corresponding to the ``|0\rangle`` state:
59
59
```@example Bloch_sphere_rendering
60
60
z0 = basis(2, 0)
61
61
add_states!(b, z0)
62
-
fig, _ = render(b)
63
-
fig
62
+
scene = render(b)
63
+
scene
64
64
```
65
65
66
66
## Add multiple data
@@ -69,8 +69,8 @@ We can also plot multiple points, vectors, and states at the same time by passin
69
69
70
70
```@example Bloch_sphere_rendering
71
71
clear!(b)
72
-
fig, _ = render(b)
73
-
fig
72
+
scene = render(b)
73
+
scene
74
74
```
75
75
76
76
Now on the same [`Bloch`](@ref) sphere, we can plot the three states via [`add_states!`](@ref) associated with the `x`, `y`, and `z` directions:
@@ -80,8 +80,8 @@ x = basis(2, 0) + basis(2, 1)
80
80
y = basis(2, 0) + im * basis(2, 1)
81
81
z = basis(2, 0)
82
82
add_states!(b, [x, y, z])
83
-
fig, _ = render(b)
84
-
fig
83
+
scene = render(b)
84
+
scene
85
85
```
86
86
87
87
!!! note "State normalization"
@@ -93,8 +93,8 @@ A similar method works for adding vectors:
93
93
clear!(b)
94
94
vecs = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
95
95
add_vectors!(b, vecs)
96
-
fig, _ = render(b)
97
-
fig
96
+
scene = render(b)
97
+
scene
98
98
```
99
99
100
100
# Add lines and arcs
@@ -104,8 +104,8 @@ You can also add lines and arcs via [`add_line!`](@ref) and [`add_arc!`](@ref) r
104
104
```@example Bloch_sphere_rendering
105
105
add_line!(b, x, y)
106
106
add_arc!(b, y, z)
107
-
fig, _ = render(b)
108
-
fig
107
+
scene = render(b)
108
+
scene
109
109
```
110
110
111
111
## Add multiple points
@@ -121,8 +121,8 @@ yp = sin.(th)
121
121
zp = zeros(20)
122
122
pnts = [xp, yp, zp]
123
123
add_points!(b, pnts)
124
-
fig, ax = render(b)
125
-
fig
124
+
scene = render(b)
125
+
scene
126
126
```
127
127
128
128
Notice that, in contrast to states or vectors, each point remains the same color as the initial point. This is because adding multiple data points using [`add_points!`](@ref) is interpreted, by default, to correspond to a single data point (single qubit state) plotted at different times. This is very useful when visualizing the dynamics of a qubit. If we want to plot additional qubit states we can call additional [`add_points!`](@ref) function:
@@ -132,8 +132,8 @@ xz = zeros(20)
132
132
yz = sin.(th)
133
133
zz = cos.(th)
134
134
add_points!(b, [xz, yz, zz])
135
-
fig, ax = render(b)
136
-
fig
135
+
scene = render(b)
136
+
scene
137
137
```
138
138
139
139
The color and shape of the data points is varied automatically by [`Bloch`](@ref). Notice how the color and point markers change for each set of data. Again, we have had to call [`add_points!`](@ref) twice because adding more than one set of multiple data points is not supported by the [`add_points!`](@ref) function.
Now, the data points cycle through a variety of predefined colors. Now lets add another set of points, but this time we want the set to be a single color, representing say a qubit going from the ``|0\rangle`` state to the ``|1\rangle`` state in the `y-z` plane:
156
156
157
157
```@example Bloch_sphere_rendering
158
158
pnts = [xz, yz, zz]
159
159
add_points!(b, pnts) # no `meth=:m`
160
-
fig, ax = render(b)
161
-
fig
160
+
scene = render(b)
161
+
scene
162
162
```
163
163
164
164
## [Configuring the Bloch sphere](@id doc:Configuring-the-Bloch-sphere)
@@ -172,7 +172,7 @@ At the end of the last section we saw that the colors and marker shapes of the d
172
172
|`b.lines`| Lines to draw on the sphere (points, style, properties) |`Vector{Tuple{Vector{Vector{Float64}},String}}()` (empty) |
173
173
|`b.arcs`| Arcs to draw on the sphere |`Vector{Vector{Vector{Float64}}}()` (empty) |
174
174
|`b.font_color`| Color of axis labels and text |`"black"`|
175
-
|`b.font_size`| Font size for labels |`15`|
175
+
|`b.font_size`| Font size for labels |`20`|
176
176
|`b.frame_alpha`| Transparency of the frame background |`0.1`|
177
177
|`b.frame_color`| Background color of the frame |`"gray"`|
178
178
|`b.frame_limit`| Axis limits for the 3D frame (symmetric around origin) |`1.2`|
0 commit comments