diff --git a/CHANGELOG.md b/CHANGELOG.md index 153eb036f..208ea97e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Improve efficiency of `bloch_redfield_tensor` by avoiding unnecessary conversions. ([#509]) - Support `SciMLOperators v1.4+`. ([#470]) +- Fix compatibility with `Makie v0.24+`. ([#513]) ## [v0.33.0] Release date: 2025-07-22 @@ -272,3 +273,4 @@ Release date: 2024-11-13 [#506]: https://github.com/qutip/QuantumToolbox.jl/issues/506 [#507]: https://github.com/qutip/QuantumToolbox.jl/issues/507 [#509]: https://github.com/qutip/QuantumToolbox.jl/issues/509 +[#513]: https://github.com/qutip/QuantumToolbox.jl/issues/513 diff --git a/Project.toml b/Project.toml index b93326f38..745abe013 100644 --- a/Project.toml +++ b/Project.toml @@ -55,7 +55,7 @@ KernelAbstractions = "0.9.2" LaTeXStrings = "1.2" LinearAlgebra = "1" LinearSolve = "2, 3" -Makie = "0.20, 0.21, 0.22, 0.23" +Makie = "0.24" OrdinaryDiffEqCore = "1" OrdinaryDiffEqTsit5 = "1" Pkg = "1" diff --git a/docs/src/users_guide/plotting_the_bloch_sphere.md b/docs/src/users_guide/plotting_the_bloch_sphere.md index 59411831a..8bb5facfe 100644 --- a/docs/src/users_guide/plotting_the_bloch_sphere.md +++ b/docs/src/users_guide/plotting_the_bloch_sphere.md @@ -195,8 +195,9 @@ At the end of the last section we saw that the colors and marker shapes of the d | `b.sphere_color` | Color of Bloch sphere surface | `0.2` | | `b.sphere_alpha` | Transparency of sphere surface | `"#FFDDDD"` | | `b.vector_color` | Colors for vectors | `["green", "#CC6600", "blue", "red"]` | -| `b.vector_width` | Width of vectors | `0.025` | -| `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]` | +| `b.vector_width` | Width of vectors | `0.02` | +| `b.vector_tiplength` | Length of vector arrow head | `0.08` | +| `b.vector_tipradius` | Radius of vector arrow head | `0.05` | | `b.view` | Azimuthal and elevation viewing angles in degrees | `[30, 30]` | | `b.xlabel` | Labels for x-axis | `[L"x", ""]` (``+x`` and ``-x``) | | `b.xlpos` | Positions of x-axis labels | `[1.2, -1.2]` | diff --git a/ext/QuantumToolboxMakieExt.jl b/ext/QuantumToolboxMakieExt.jl index 3fcaaeee5..4c6e8cc0b 100644 --- a/ext/QuantumToolboxMakieExt.jl +++ b/ext/QuantumToolboxMakieExt.jl @@ -22,7 +22,7 @@ import Makie: Sphere, lines!, scatter!, - arrows!, + arrows3d!, text!, Point3f, mesh!, @@ -656,26 +656,17 @@ Scales vectors appropriately and adds `3D` arrow markers. function _plot_vectors!(b::Bloch, lscene) isempty(b.vectors) && return nothing - arrow_head_length = b.vector_arrowsize[3] for (i, v) in enumerate(b.vectors) color = get(b.vector_color, i, RGBAf(0.2, 0.5, 0.8, 0.9)) - nv = norm(v) - (arrow_head_length < nv) || throw( - ArgumentError( - "The length of vector arrow head (Bloch.vector_arrowsize[3]=$arrow_head_length) should be shorter than vector norm: $nv", - ), - ) - # multiply by the following factor makes the end point of arrow head represent the actual vector position. - vec = (1 - arrow_head_length / nv) * Vec3f(v...) - arrows!( + arrows3d!( lscene, [Point3f(0, 0, 0)], - [vec], + [v], color = color, - linewidth = b.vector_width, - arrowsize = Vec3f(b.vector_arrowsize...), - arrowcolor = color, + shaftradius = b.vector_width, + tiplength = b.vector_tiplength, + tipradius = b.vector_tipradius, rasterize = 3, ) end diff --git a/src/visualization.jl b/src/visualization.jl index 273a9c21a..396f76959 100644 --- a/src/visualization.jl +++ b/src/visualization.jl @@ -102,8 +102,9 @@ A structure representing a Bloch sphere visualization for quantum states. Availa ## Vector properties - `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]` +- `vector_width::Float64`: Width of vectors. Default: `0.02` +- `vector_tiplength::Float64`: Length of vector arrow head. Default: `0.08` +- `vector_tipradius::Float64`: Radius of vector arrow head. Default: `0.05` ## Layout properties @@ -137,8 +138,9 @@ A structure representing a Bloch sphere visualization for quantum states. Availa sphere_alpha::Float64 = 0.2 sphere_color::String = "#FFDDDD" vector_color::Vector{String} = ["green", "#CC6600", "blue", "red"] - vector_width::Float64 = 0.025 - vector_arrowsize::Vector{Float64} = [0.07, 0.08, 0.08] + vector_width::Float64 = 0.02 + vector_tiplength::Float64 = 0.08 + vector_tipradius::Float64 = 0.05 view::Vector{Int} = [30, 30] xlabel::Vector{AbstractString} = [L"x", ""] xlpos::Vector{Float64} = [1.2, -1.2] diff --git a/test/ext-test/cpu/makie/makie_ext.jl b/test/ext-test/cpu/makie/makie_ext.jl index 6f4b0c607..cf4e3eaf9 100644 --- a/test/ext-test/cpu/makie/makie_ext.jl +++ b/test/ext-test/cpu/makie/makie_ext.jl @@ -15,14 +15,14 @@ @test fig isa Figure @test ax isa Axis @test hm isa Heatmap - @test all(isapprox.(hm[3].val, wig, atol = 1e-6)) + @test all(isapprox.(hm[3].value.x, wig, atol = 1e-6)) fig, ax, surf = plot_wigner(ψ; library = Val(:Makie), xvec = xvec, yvec = yvec, projection = Val(:three_dim), colorbar = true) @test fig isa Figure @test ax isa Axis3 @test surf isa Surface - @test all(isapprox.(surf[3].val, wig, atol = 1e-6)) + @test all(isapprox.(surf[3].value.x, wig, atol = 1e-6)) fig = Figure() pos = fig[2, 3] @@ -150,8 +150,6 @@ end @test false @info "Render threw unexpected error" exception=e end - b.vector_arrowsize = [0.7, 0.8, 1.5] # 1.5 is the length of arrow head (too long) - @test_throws ArgumentError render(b) b = Bloch() ψ₁ = normalize(basis(2, 0) + basis(2, 1))