# Need help plotting using Blink and Interact

Hi there

I have a simple interactive plot (in Pluto) that is slow - and should benefit from using Blink instead. I have spent the last day trying to make it work, but I just can’t figure out how to.

Could someone please show me how to translate this into a plot that displays interactively in Blink? I’m agnostic to the back-end - PlotlyJS / InspectDR. A working example would be really really good!

``````
@bind θ Slider(0:0.05:2π+0.1, show_value=true)

Q = [cos(θ) -sin(θ)
sin(θ) cos(θ)]

Λ = [2 0; 0 0.5]
QΛQh(x) = Q * Λ * Q' * x

ts = 0:0.01:2π
Qs = [QΛQh([cos(t), sin(t)]) for t in ts]
xs = [q[1] for q in Qs]
ys = [q[2] for q in Qs]

plot(cos, sin, 0, 2π, ratio=1) # Plots a circle
plot!(xs, ys)
``````

After this - I try and also show a current ‘x’ vector, and its translation on the same plot using plot!. But if someone can please show me how to send the above to Blink (with Interact or Makie or anything)- I can then do the rest.

Many thanks!

1 Like

OK - to anyone else with this question, the following code seems to work - EXCEPT if you choose plotlyjs() as the backend. Not sure why.

gr() is quite fast - plotly() is laggy.

``````using Interact, Plots, Blink

gr() # plotly, inspectdr work too - but not plotlyjs - not sure why

win = Window()

mp = @manipulate for θ₁=0:0.05:2π+0.1, θ in 0:0.05:2π+0.1

pt_x = [cos(θ₁), sin(θ₁)]

Q = [cos(θ) -sin(θ)

sin(θ) cos(θ)]

Λ = [2 0; 0 0.5]

QΛQh(x) = Q * Λ * Q' * x

ts = 0:0.01:2π

Qs = [QΛQh([cos(t), sin(t)]) for t in ts]

xs = [q[1] for q in Qs]

ys = [q[2] for q in Qs]

plot(cos, sin, 0, 2π, ratio=1)

plot!(xs, ys)

plot!([0, pt_x[1]], [0, pt_x[2]])

plot!([0, QΛQh(pt_x)[1]], [0, QΛQh(pt_x)[2]])

end

body!(win, vbox(mp))

``````