-
Notifications
You must be signed in to change notification settings - Fork 32
Improve Bloch alignment with qutip
#489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -414,8 +414,8 @@ function _draw_bloch_sphere!(b::Bloch, lscene) | |
|
|
||
| # highlight circles for XY and XZ planes | ||
| φ = range(0, 2π, length = 100) | ||
| lines!(lscene, [Point3f(cos(φi), sin(φi), 0) for φi in φ]; color = b.frame_color, linewidth = 1.0) # XY | ||
| lines!(lscene, [Point3f(cos(φi), 0, sin(φi)) for φi in φ]; color = b.frame_color, linewidth = 1.0) # XZ | ||
| lines!(lscene, [Point3f(cos(φi), sin(φi), 0) for φi in φ]; color = b.frame_color, linewidth = b.frame_width) # XY | ||
| lines!(lscene, [Point3f(cos(φi), 0, sin(φi)) for φi in φ]; color = b.frame_color, linewidth = b.frame_width) # XZ | ||
|
|
||
| # other curves of longitude (with polar angle φ and azimuthal angle θ) | ||
| φ_curve = range(0, 2π, 600) | ||
|
|
@@ -424,7 +424,7 @@ function _draw_bloch_sphere!(b::Bloch, lscene) | |
| x_line = radius * sin.(φ_curve) .* cos(θi) | ||
| y_line = radius * sin.(φ_curve) .* sin(θi) | ||
| z_line = radius * cos.(φ_curve) | ||
| lines!(lscene, x_line, y_line, z_line; color = b.frame_color, alpha = b.frame_alpha) | ||
| lines!(lscene, x_line, y_line, z_line; color = b.frame_color, alpha = b.frame_alpha, linewidth = b.frame_width) | ||
| end | ||
|
|
||
| # other curves of latitude (with polar angle φ and azimuthal angle θ) | ||
|
|
@@ -434,7 +434,7 @@ function _draw_bloch_sphere!(b::Bloch, lscene) | |
| x_ring = radius * sin(ϕ) .* cos.(θ_curve) | ||
| y_ring = radius * sin(ϕ) .* sin.(θ_curve) | ||
| z_ring = fill(radius * cos(ϕ), length(θ_curve)) | ||
| lines!(lscene, x_ring, y_ring, z_ring; color = b.frame_color, alpha = b.frame_alpha) | ||
| lines!(lscene, x_ring, y_ring, z_ring; color = b.frame_color, alpha = b.frame_alpha, linewidth = b.frame_width) | ||
| end | ||
| return nothing | ||
| end | ||
|
|
@@ -558,14 +558,11 @@ function _plot_points!(b::Bloch, lscene) | |
| end | ||
| end | ||
| if style in (:s, :m) | ||
| xs = raw_x[indperm] | ||
| ys = raw_y[indperm] | ||
| zs = raw_z[indperm] | ||
| scatter!( | ||
| lscene, | ||
| xs, | ||
| ys, | ||
| zs; | ||
| raw_x[indperm], | ||
| raw_y[indperm], | ||
| raw_z[indperm]; | ||
| color = colors, | ||
| markersize = b.point_size[mod1(k, length(b.point_size))], | ||
| marker = marker, | ||
|
|
@@ -575,11 +572,8 @@ function _plot_points!(b::Bloch, lscene) | |
| ) | ||
|
|
||
| elseif style == :l | ||
| xs = raw_x | ||
| ys = raw_y | ||
| zs = raw_z | ||
| c = isa(colors, Vector) ? colors[1] : colors | ||
| lines!(lscene, xs, ys, zs; color = c, linewidth = 2.0, transparency = alpha < 1.0, alpha = alpha) | ||
| lines!(lscene, raw_x, raw_y, raw_z; color = c, transparency = alpha < 1.0, alpha = alpha) | ||
| end | ||
| end | ||
| return nothing | ||
|
|
@@ -613,7 +607,7 @@ function _plot_lines!(b::Bloch, lscene) | |
| else | ||
| :solid | ||
| end | ||
| lines!(lscene, x, y, z; color = color, linewidth = 1.0, linestyle = linestyle) | ||
| lines!(lscene, x, y, z; color = color, linestyle = linestyle) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I remove the |
||
| end | ||
| return nothing | ||
| end | ||
|
|
@@ -643,7 +637,7 @@ function _plot_arcs!(b::Bloch, lscene) | |
| end | ||
| t_range = range(0, θ, length = 100) | ||
| arc_points = [Point3f((v1 * cos(t) + cross(n, v1) * sin(t))) for t in t_range] | ||
| lines!(lscene, arc_points; color = RGBAf(0.8, 0.4, 0.1, 0.9), linewidth = 2.0, linestyle = :solid) | ||
| lines!(lscene, arc_points; color = "blue", linestyle = :solid) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed the default color of Also, I remove the |
||
| end | ||
| return nothing | ||
| end | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,30 +79,31 @@ A structure representing a Bloch sphere visualization for quantum states. Availa | |
|
|
||
| ## Style properties | ||
|
|
||
| - `font_color::String`: Color of axis labels and text | ||
| - `font_color::String`: Color of axis labels and text. Default: `"black"` | ||
| - `font_size::Int`: Font size for labels. Default: `20` | ||
| - `frame_alpha::Float64`: Transparency of the wire frame | ||
| - `frame_color::String`: Color of the wire frame | ||
| - `frame_alpha::Float64`: Transparency of the wire frame. Default: `0.2` | ||
| - `frame_color::String`: Color of the wire frame. Default: `"gray"` | ||
| - `frame_width::Float64` : Width of wire frame. Default: `1.0` | ||
|
|
||
| ## Point properties | ||
|
|
||
| - `point_default_color::Vector{String}}`: Default color cycle for points | ||
| - `point_color::Vector{String}}`: List of colors for Bloch point markers to cycle through | ||
| - `point_default_color::Vector{String}}`: Default color cycle for points. Default: `["blue", "red", "green", "#CC6600"]` | ||
| - `point_color::Vector{String}}`: List of colors for Bloch point markers to cycle through. Default: `Union{Nothing,String}[]` | ||
| - `point_marker::Vector{Symbol}}`: List of point marker shapes to cycle through. Default: `[:circle, :rect, :diamond, :utriangle]` | ||
| - `point_size::Vector{Int}}`: List of point marker sizes (not all markers look the same size when plotted) | ||
| - `point_style::Vector{Symbol}}`: List of marker styles | ||
| - `point_alpha::Vector{Float64}}`: List of marker transparencies | ||
| - `point_size::Vector{Int}}`: List of point marker sizes (not all markers look the same size when plotted). Default: `[5.5, 6.2, 6.5, 7.5]` | ||
| - `point_style::Vector{Symbol}}`: List of marker styles. Default: `Symbol[]` | ||
| - `point_alpha::Vector{Float64}}`: List of marker transparencies. Default: `Float64[]` | ||
|
|
||
| ## Sphere properties | ||
|
|
||
| - `sphere_color::String`: Color of Bloch sphere surface | ||
| - `sphere_color::String`: Color of Bloch sphere surface. Default: `"#FFDDDD"` | ||
| - `sphere_alpha::Float64`: Transparency of sphere surface. Default: `0.2` | ||
|
|
||
| ## Vector properties | ||
|
|
||
| - `vector_color::Vector{String}`: Colors for vectors | ||
| - `vector_width::Float64`: Width of vectors | ||
| - `vector_arrowsize::Vector{Float64}`: 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. | ||
| - `vector_color::Vector{String}`: Colors for vectors. Default: `["green", "#CC6600", "blue", "red"]` | ||
| - `vector_width::Float64`: Width of vectors. Default: `0.025` | ||
| - `vector_arrowsize::Vector{Float64}`: 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. Default: `[0.07, 0.08, 0.08]` | ||
|
|
||
| ## Layout properties | ||
|
|
||
|
|
@@ -124,8 +125,9 @@ A structure representing a Bloch sphere visualization for quantum states. Availa | |
| arcs::Vector{Vector{Vector{Float64}}} = Vector{Vector{Vector{Float64}}}() | ||
| font_color::String = "black" | ||
| font_size::Int = 20 | ||
| frame_alpha::Float64 = 0.1 | ||
| frame_alpha::Float64 = 0.2 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Increase the |
||
| frame_color::String = "gray" | ||
| frame_width::Float64 = 1.0 | ||
| point_default_color::Vector{String} = ["blue", "red", "green", "#CC6600"] | ||
| point_color::Vector{Union{Nothing,String}} = Union{Nothing,String}[] | ||
| point_marker::Vector{Symbol} = [:circle, :rect, :diamond, :utriangle] | ||
|
|
@@ -405,7 +407,7 @@ function add_states!(b::Bloch, states::Vector{<:QuantumObject}; kind::Symbol = : | |
| if kind == :vector | ||
| add_vectors!(b, vecs) | ||
| elseif kind == :point | ||
| add_points!(b, hcat(vecs...), kwargs...) | ||
| add_points!(b, hcat(vecs...); kwargs...) | ||
| else | ||
| throw(ArgumentError("Invalid kind = :$kind")) | ||
| end | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remove the
linewidthhere so thatMakiecan automatically decide for us.