Skip to content

Commit 26cd2fb

Browse files
committed
fix incorrect rendering for Bloch in docs
1 parent b6dec38 commit 26cd2fb

File tree

4 files changed

+36
-34
lines changed

4 files changed

+36
-34
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
1212
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
1313
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
1414
IncompleteLU = "40713840-3770-5561-ab4c-a76e7d0d7895"
15+
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
1516
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1617
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
1718
OrdinaryDiffEqCore = "bbf590c4-e513-4bbe-9b18-05decba2e5d8"
@@ -51,6 +52,7 @@ GPUArrays = "10, 11"
5152
Graphs = "1.7"
5253
IncompleteLU = "0.2"
5354
KernelAbstractions = "0.9.2"
55+
LaTeXStrings = "1.2"
5456
LinearAlgebra = "1"
5557
LinearSolve = "2, 3"
5658
Makie = "0.20, 0.21, 0.22"

docs/src/users_guide/plotting_the_bloch_sphere.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,12 @@ At the end of the last section we saw that the colors and marker shapes of the d
188188
| `b.vector_width` | Width of vectors | `0.025` |
189189
| `b.vector_arrowsize` | Arrow size parameters as (head length, head width, stem width) | `(0.07, 0.08, 0.08)` |
190190
| `b.view` | Azimuthal and elevation viewing angles in degrees | `(-60, 30)` |
191-
| `b.xlabel` | Labels for x-axis | `[L"x", ""]` |
192-
| `b.xlpos` | Positions of x-axis labels | `[1.0, -1.0]` |
193-
| `b.ylabel` | Labels for y-axis | `[L"y", ""]` |
194-
| `b.ylpos` | Positions of y-axis labels | `[1.0, -1.0]` |
195-
| `b.zlabel` | Labels for z-axis | `[1.0, -1.0]` |
196-
| `b.zlpos` | Positions of z-axis labels | `[L"\|0\rangle", L"\|1\rangle"]` |
191+
| `b.xlabel` | Labels for x-axis | `(L"x", "")` |
192+
| `b.xlpos` | Positions of x-axis labels | `(1.0, -1.0)` |
193+
| `b.ylabel` | Labels for y-axis | `(L"y", "")` |
194+
| `b.ylpos` | Positions of y-axis labels | `(1.0, -1.0)` |
195+
| `b.zlabel` | Labels for z-axis | `(L"\|0\rangle", L"\|1\rangle)"` |
196+
| `b.zlpos` | Positions of z-axis labels | `(1.0, -1.0)` |
197197

198198
These properties can also be accessed via the `print` command:
199199

ext/QuantumToolboxMakieExt.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -663,60 +663,60 @@ function _add_labels!(b::Bloch, ax)
663663
label_color = parse(RGBf, b.font_color)
664664
label_size = b.font_size
665665
offset_scale = b.frame_limit
666-
if !isempty(b.xlabel) && !isempty(b.xlabel[1])
666+
if b.xlabel[1] != ""
667667
text!(
668668
ax,
669-
L"\textbf{x}",
669+
b.xlabel[1],
670670
position = Point3f(0, -offset_scale * b.xlpos[1], 0),
671671
color = label_color,
672672
fontsize = label_size,
673673
align = (:center, :center),
674674
)
675675
end
676-
if length(b.xlabel) > 1 && !isempty(b.xlabel[2])
676+
if b.xlabel[2] != ""
677677
text!(
678678
ax,
679-
L"\textbf{-x}",
679+
b.xlabel[2],
680680
position = Point3f(0, -offset_scale * b.xlpos[2], 0),
681681
color = label_color,
682682
fontsize = label_size,
683683
align = (:center, :center),
684684
)
685685
end
686-
if !isempty(b.ylabel) && !isempty(b.ylabel[1])
686+
if b.ylabel[1] != ""
687687
text!(
688688
ax,
689-
L"\textbf{y}",
689+
b.ylabel[1],
690690
position = Point3f(offset_scale * b.ylpos[1], 0, 0),
691691
color = label_color,
692692
fontsize = label_size,
693693
align = (:center, :center),
694694
)
695695
end
696-
if length(b.ylabel) > 1 && !isempty(b.ylabel[2])
696+
if b.ylabel[2] != ""
697697
text!(
698698
ax,
699-
L"\textbf{-y}",
699+
b.ylabel[2],
700700
position = Point3f(offset_scale * b.ylpos[2], 0, 0),
701701
color = label_color,
702702
fontsize = label_size,
703703
align = (:center, :center),
704704
)
705705
end
706-
if !isempty(b.zlabel) && !isempty(b.zlabel[1])
706+
if b.zlabel[1] != ""
707707
text!(
708708
ax,
709-
L"\mathbf{|0\rangle}",
709+
b.zlabel[1],
710710
position = Point3f(0, 0, offset_scale * b.zlpos[1]),
711711
color = label_color,
712712
fontsize = label_size,
713713
align = (:center, :center),
714714
)
715715
end
716-
if length(b.zlabel) > 1 && !isempty(b.zlabel[2])
716+
if b.zlabel[2] != ""
717717
text!(
718718
ax,
719-
L"\mathbf{|1\rangle}",
719+
b.zlabel[2],
720720
position = Point3f(0, 0, offset_scale * b.zlpos[2]),
721721
color = label_color,
722722
fontsize = label_size,

src/visualization.jl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ A structure representing a Bloch sphere visualization for quantum states.
8080
## Style properties
8181
8282
- `font_color::String`: Color of axis labels and text
83-
- `font_size::Int`: Font size for labels (default: 15)
83+
- `font_size::Int`: Font size for labels. Default: `15`
8484
- `frame_alpha::Float64`: Transparency of the frame background
8585
- `frame_color::String`: Background color of the frame
8686
- `frame_limit::Float64`: Axis limits for the 3D frame (symmetric around origin)
@@ -89,15 +89,15 @@ A structure representing a Bloch sphere visualization for quantum states.
8989
9090
- `point_default_color::Vector{String}}`: Default color cycle for points
9191
- `point_color::Vector{String}}`: List of colors for Bloch point markers to cycle through
92-
- `point_marker::Vector{Symbol}}`: List of point marker shapes to cycle through (default: [:circle, :rect, :diamond, :utriangle])
92+
- `point_marker::Vector{Symbol}}`: List of point marker shapes to cycle through. Default: `[:circle, :rect, :diamond, :utriangle]`
9393
- `point_size::Vector{Int}}`: List of point marker sizes (not all markers look the same size when plotted)
9494
- `point_style::Vector{Symbol}}`: List of marker styles
9595
- `point_alpha::Vector{Float64}}`: List of marker transparencies
9696
9797
## Sphere properties
9898
9999
- `sphere_color::String`: Color of Bloch sphere surface
100-
- `sphere_alpha::Float64`: Transparency of sphere surface (default: 0.2)
100+
- `sphere_alpha::Float64`: Transparency of sphere surface. Default: `0.2`
101101
102102
# Vector properties
103103
@@ -107,15 +107,15 @@ A structure representing a Bloch sphere visualization for quantum states.
107107
108108
## Layout properties
109109
110-
- `view::Tuple{Int,Int}}`: Azimuthal and elevation viewing angles in degrees (default: (-60, 30))
110+
- `view::Tuple{Int,Int}}`: Azimuthal and elevation viewing angles in degrees. Default: `(-60, 30)`
111111
112112
## Label properties
113-
- `xlabel::Vector{String}}`: Labels for x-axis (default: [raw"$x$", ""])
114-
- `xlpos::Vector{Float64}}`: Positions of x-axis labels (default: [1.0, -1.0])
115-
- `ylabel::Vector{String}}`: Labels for y-axis (default: [raw"$y$", ""])
116-
- `ylpos::Vector{Float64}}`: Positions of y-axis labels (default: [1.0, -1.0])
117-
- `zlabel::Vector{String}}`: Labels for z-axis (default: [raw"$|0\rangle$", raw"$|1\rangle$"])
118-
- `zlpos::Vector{Float64}}`: Positions of z-axis labels (default: [1.0, -1.0])
113+
- `xlabel::Tuple{AbstractString,AbstractString}`: Labels for x-axis. Default: `(L"x", "")`
114+
- `xlpos::Tuple{Float64,Float64}`: Positions of x-axis labels. Default: `(1.0, -1.0)`
115+
- `ylabel::Tuple{AbstractString,AbstractString}`: Labels for y-axis. Default: `(L"y", "")`
116+
- `ylpos::Tuple{Float64,Float64}`: Positions of y-axis labels. Default: `(1.0, -1.0)`
117+
- `zlabel::Tuple{AbstractString,AbstractString}`: Labels for z-axis. Default: `(L"|0\rangle", L"|1\rangle")`
118+
- `zlpos::Tuple{Float64,Float64}`: Positions of z-axis labels. Default: `(1.0, -1.0)`
119119
"""
120120
@kwdef mutable struct Bloch
121121
points::Vector{Matrix{Float64}} = Vector{Matrix{Float64}}()
@@ -139,12 +139,12 @@ A structure representing a Bloch sphere visualization for quantum states.
139139
vector_width::Float64 = 0.025
140140
vector_arrowsize::NTuple{3,Real} = (0.07, 0.08, 0.08)
141141
view::Tuple{Int,Int} = (-60, 30)
142-
xlabel::Vector{String} = [raw"$x$", raw""]
143-
xlpos::Vector{Float64} = [1.0, -1.0]
144-
ylabel::Vector{String} = [raw"$y$", ""]
145-
ylpos::Vector{Float64} = [1.0, -1.0]
146-
zlabel::Vector{String} = [raw"$|0\rangle$", raw"$|1\rangle$"]
147-
zlpos::Vector{Float64} = [1.0, -1.0]
142+
xlabel::Tuple{AbstractString,AbstractString} = (L"x", "")
143+
xlpos::Tuple{Float64,Float64} = (1.0, -1.0)
144+
ylabel::Tuple{AbstractString,AbstractString} = (L"y", "")
145+
ylpos::Tuple{Float64,Float64} = (1.0, -1.0)
146+
zlabel::Tuple{AbstractString,AbstractString} = (L"|0\rangle", L"|1\rangle")
147+
zlpos::Tuple{Float64,Float64} = (1.0, -1.0)
148148
end
149149

150150
const BLOCH_DATA_FIELDS = (:points, :vectors, :lines, :arcs)

0 commit comments

Comments
 (0)