Ok the solution was very simple. When I let my brain rest on it the
solution came automatically:
f = figure()
@manipulate for θ in 0:15:90
withfig(f) do
clear(b)
add_vector(b,[θ,0])
render(b)
end
end
On Wednesday, August 10, 2016 at 4:18:43 PM UTC+2, Willem Hekman wrote:
>
> Hello all,
>
> I have been spending my time making
> http://qutip.org/docs/3.1.0/guide/guide-bloch.html work in Julia by
> translating the main parts of the source code
> http://qutip.org/docs/3.1.0/modules/qutip/bloch.html
> . <http://qutip.org/docs/3.1.0/modules/qutip/bloch.html>
>
> In short, what I've worked out is, in pseudo-code:
>
> type Bloch
> some properties.. :: of various types
> vectors ( :: Vector{Vector{Float64}} ) # Vector of vectors that can
> be plot on the sphere.
> end
>
> Bloch() = Bloch(standard properties, []) # initialize without any vectors
> to plot
>
> function add_vector(b::Bloch,vector::Vector{Float64})
> push!(b.vectors,vector)
> end
>
> function render(b::Bloch)
> plot a sphere
> plot equator
> plot x,y and z axis
> plot vectors
> style axes
> end
>
> The actual code I've written so far can be found on
> https://github.com/whekman/edX/blob/master/Other/bloch.jl . Any advice on
> my code much appreciated, I`m quite new to programming.
>
> Now *I`d love to make such rendering compatible with @manipulate*. I know
> that you can use withfig(fig) do .... end but somehow I cant figure out how
> to incorporate it in this more object style approach.
>
> Basically, I'm looking for a way to implement, in pseudo-code:
>
> b = Bloch()
> @manipulate for azimuth 0:15:90, latitude -180:15:180
> add_vector(b,azimuth,latitude)
> render(b)
> end
>
> So the goal is to have an easy way to draw points on such a sphere in an
> interactive way. Basically, I am having a hard time figuring out how to
> combine the use of such a composite type with @manipulate.
>
> Anyone know a solution?
>
> As an aside, the PyPlot code that I've written so far may be a nice,
> comprehensive example of 3D plotting using PyPlot . If so, how to make sure
> people can find it?
>
> Furthermore, any hopes of plotting Arrow3D objects from inside Julia? It
> is already possible in matplotlib
> http://stackoverflow.com/questions/29188612/arrows-in-matplotlib-using-mplot3d
>
> - Willem
>