diff --git a/docs/src/users_guide/plotting_the_bloch_sphere.md b/docs/src/users_guide/plotting_the_bloch_sphere.md index 950212c33..4c144bbc0 100644 --- a/docs/src/users_guide/plotting_the_bloch_sphere.md +++ b/docs/src/users_guide/plotting_the_bloch_sphere.md @@ -24,7 +24,8 @@ b = Bloch() 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: ```@example Bloch_sphere_rendering -fig, _ = render(b) +fig = Figure(size = (700, 700), figure_padding = 0) +fig, ax = render(b,location = fig[1,1]) fig ``` @@ -37,7 +38,8 @@ As an example, we can add a single data point via [`add_points!`](@ref): ```@example Bloch_sphere_rendering pnt = [1 / sqrt(3), 1 / sqrt(3), 1 / sqrt(3)] add_points!(b, pnt) -fig, _ = render(b) +fig = Figure(size = (700, 700), figure_padding = 0) +fig, ax = render(b,location = fig[1,1]) fig ``` @@ -48,7 +50,8 @@ Add a single vector via [`add_vectors!`](@ref): ```@example Bloch_sphere_rendering vec = [0, 1, 0] add_vectors!(b, vec) -fig, _ = render(b) +fig = Figure(size = (700, 700), figure_padding = 0) +fig, ax = render(b,location = fig[1,1]) fig ``` @@ -59,7 +62,8 @@ Add another vector corresponding to the ``|0\rangle`` state: ```@example Bloch_sphere_rendering z0 = basis(2, 0) add_states!(b, z0) -fig, _ = render(b) +fig = Figure(size = (700, 700), figure_padding = 0) +fig, ax = render(b,location = fig[1,1]) fig ``` @@ -69,7 +73,8 @@ We can also plot multiple points, vectors, and states at the same time by passin ```@example Bloch_sphere_rendering clear!(b) -fig, _ = render(b) +fig = Figure(size = (700, 700), figure_padding = 0) +fig, ax = render(b,location = fig[1,1]) fig ``` @@ -80,7 +85,8 @@ x = basis(2, 0) + basis(2, 1) y = basis(2, 0) - im * basis(2, 1) z = basis(2, 0) add_states!(b, [x, y, z]) -fig, _ = render(b) +fig = Figure(size = (700, 700), figure_padding = 0) +fig, ax = render(b,location = fig[1,1]) fig ``` @@ -93,7 +99,8 @@ A similar method works for adding vectors: clear!(b) vecs = [[1, 0, 0], [0, 1, 0], [0, 0, 1]] add_vectors!(b, vecs) -fig, _ = render(b) +fig = Figure(size = (700, 700), figure_padding = 0) +fig, ax = render(b,location = fig[1,1]) fig ``` @@ -104,7 +111,8 @@ You can also add lines and arcs via [`add_line!`](@ref) and [`add_arc!`](@ref) r ```@example Bloch_sphere_rendering add_line!(b, x, y) add_arc!(b, y, z) -fig, _ = render(b) +fig = Figure(size = (700, 700), figure_padding = 0) +fig, ax = render(b,location = fig[1,1]) fig ``` @@ -121,7 +129,8 @@ yp = sin.(th) zp = zeros(20) pnts = [xp, yp, zp] add_points!(b, pnts) -fig, ax = render(b) +fig = Figure(size = (700, 700), figure_padding = 0) +fig, ax = render(b,location = fig[1,1]) fig ``` @@ -132,7 +141,8 @@ xz = zeros(20) yz = sin.(th) zz = cos.(th) add_points!(b, [xz, yz, zz]) -fig, ax = render(b) +fig = Figure(size = (700, 700), figure_padding = 0) +fig, ax = render(b,location = fig[1,1]) fig ``` @@ -148,7 +158,8 @@ yp = sin.(th) zp = zeros(20) pnts = [xp, yp, zp] add_points!(b, pnts, meth=:m) # add `meth=:m` to signify 'multi' colored points -fig, ax = render(b) +fig = Figure(size = (700, 700), figure_padding = 0) +fig, ax = render(b,location = fig[1,1]) fig ``` @@ -157,7 +168,8 @@ Now, the data points cycle through a variety of predefined colors. Now lets add ```@example Bloch_sphere_rendering pnts = [xz, yz, zz] add_points!(b, pnts) # no `meth=:m` -fig, ax = render(b) +fig = Figure(size = (700, 700), figure_padding = 0) +fig, ax = render(b,location = fig[1,1]) fig ``` @@ -200,4 +212,4 @@ These properties can also be accessed via the `print` command: ```@example Bloch_sphere_rendering b = Bloch() print(b) -``` \ No newline at end of file +``` diff --git a/src/visualization.jl b/src/visualization.jl index 7cd9613fb..552d65371 100644 --- a/src/visualization.jl +++ b/src/visualization.jl @@ -555,4 +555,4 @@ plot_bloch( kwargs..., ) where {OpType<:Union{Ket,Bra,Operator}} = plot_bloch(makeVal(library), state; kwargs...) plot_bloch(::Val{T}, state::QuantumObject{OpType}; kwargs...) where {T,OpType<:Union{Ket,Bra,Operator}} = - throw(ArgumentError("The specified plotting library $T is not available. Try running `using $T` first.")) + throw(ArgumentError("The specified plotting library $T is not available. Try running `using $T` first.")) \ No newline at end of file