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
Plot the [Wigner quasipropability distribution](https://en.wikipedia.org/wiki/Wigner_quasiprobability_distribution) of `state` using the [CairoMakie](https://github.com/MakieOrg/Makie.jl/tree/master/CairoMakie) plotting library.
21
+
22
+
Note that CairoMakie must first be imported before using this function.
23
+
24
+
# Arguments
25
+
- `library::Val{:CairoMakie}`: The plotting library to use.
26
+
- `state::QuantumObject`: The quantum state for which the Wigner function is calculated. It can be either a [`KetQuantumObject`](@ref), [`BraQuantumObject`](@ref), or [`OperatorQuantumObject`](@ref).
27
+
- `xvec::AbstractVector`: The x-coordinates of the phase space grid. Default is # TODO
28
+
- `yvec::AbstractVector`: The y-coordinates of the phase space grid. Default is # TODO
29
+
- `g::Real`: The scaling factor related to the value of ``\hbar`` in the commutation relation ``[x, y] = i \hbar`` via ``\hbar=2/g^2``.
30
+
- `method::WignerSolver`: The method used to calculate the Wigner function. It can be either `WignerLaguerre()` or `WignerClenshaw()`, with `WignerClenshaw()` as default. The `WignerLaguerre` method has the optional `parallel` and `tol` parameters, with default values `true` and `1e-14`, respectively.
31
+
- `projection::Union{Val,Symbol}`: Wheather to plot the Wigner function in 2D or 3D. It can be either `Val(:two_dim)` or `Val(:three_dim)`, with `Val(:two_dim)` as default.
32
+
- `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`.
33
+
- `colorbar::Bool`: Whether to include a colorbar in the plot. Default is `false`.
34
+
- `kwargs...`: Additional keyword arguments to pass to the plotting function.
35
+
36
+
# Returns
37
+
- `fig`: The figure object.
38
+
- `ax`: The axis object.
39
+
- `hm`: Either the heatmap or surface object, depending on the projection.
40
+
41
+
!!! warning "Beware of type-stability!"
42
+
If you want to keep type stability, it is recommended to use `Val(:two_dim)` and `Val(:three_dim)` instead of `:two_dim` and `:three_dim`, respectively. Also, specify the library as `Val(:CairoMakie)` See [this link](https://docs.julialang.org/en/v1/manual/performance-tips/#man-performance-value-type) and the [related Section](@ref doc:Type-Stability) about type stability for more details.
43
+
"""
6
44
function QuantumToolbox.plot_wigner(
7
45
library::Val{:CairoMakie},
8
46
state::QuantumObject{<:AbstractArray{T},OpType};
@@ -54,8 +92,8 @@ function _plot_wigner(
54
92
wig =wigner(state, xvec, yvec; g = g, method = method)
Copy file name to clipboardExpand all lines: src/visualization.jl
+16Lines changed: 16 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,21 @@
1
1
export plot_wigner
2
2
3
+
@docraw"""
4
+
plot_wigner(
5
+
state::QuantumObject{<:AbstractArray{T},OpType};
6
+
library::Union{Val,Symbol}=Val(:CairoMakie),
7
+
kwargs...
8
+
)
9
+
10
+
Plot the [Wigner quasipropability distribution](https://en.wikipedia.org/wiki/Wigner_quasiprobability_distribution) of `state` using the [`wigner`](@ref) function.
11
+
12
+
The `library` keyword argument specifies the plotting library to use, defaulting to `CairoMakie`. Note that plotting libraries must first be imported before using them with this function.
13
+
14
+
# Arguments
15
+
- `state::QuantumObject{<:AbstractArray{T},OpType}`: The quantum state for which to plot the Wigner distribution.
16
+
- `library::Union{Val,Symbol}`: The plotting library to use. Default is `Val(:CairoMakie)`.
17
+
- `kwargs...`: Additional keyword arguments to pass to the plotting function. See the documentation for the specific plotting library for more information.
0 commit comments