How to make this plot interactive?

Hi,

The following is NOT a rant about Julia, or just a little bit about its state of documentation.

I am doing the starter problems and struggling with the plotting.
Coming from Matlab… plotting life was easy:

close all
hold on
for ..
   plot( ..
end
hold off
grid on

with interactive mode (zooming, annotating…) in Matlab always on.

Now in Julia. ?plot does not give a hit: you learn that plot is not part of Julia’s Base.
OK, you have to read a manual. But which one?
You find Plots.jl, then learn that it is (just) a unifying interface to different backends.
I installed Plots, took a while to learn that the plotting behavior in a function is different from the REPL: it needs another command to actually show the plot, the command needs a handle. Things I did not find in the intro.

Finally, I got my plot:

# logistic map
using Plots
n = 100
b = zeros(n)
b[1] = 0.25
plt = plot()
for r in [2.9, 4]
    for i = 2:n
        b[i] = r*b[i-1]*(1 - b[i-1])
    end
    plot!(b)
end
display(plt)

But the plot is not interactive. You learn that not all backends have an interactive mode.
How to find out what is the default backend which comes with Plots(?) I guess its GR.
I tried to use other backends but ran into other difficulties, not all support the plot! (for hold functionality) or did not show up at all.
Makie looks very interesting, but apparently is not a backend supported by Plots.
How do you generate interactive plots?

1 Like

The Makie documentation contains a section on interactivity but I would suggest starting with the Makie intro docs first.

1 Like

The Plots.jl documentation has info about which backend do what, including which support interactivity Backends · Plots

2 Likes

Yes, I mentioned that in my question above, as well that I get errors.
Specifically, on Julia 1.7rc and packages updated, with

Pyplot:

using Plots
pyplot()
default(show = true)
plot(rand(3))
plot!(rand(5))
 Warning: `vendor()` is deprecated, use `BLAS.get_config()` and inspect the output instead
│   caller = npyinitialize() at numpy.jl:67
└ @ PyCall C:\Users\bardo\.julia\packages\PyCall\BD546\src\numpy.jl:67
ERROR: PyError ($(Expr(:escape, :(ccall(#= C:\Users\bardo\.julia\packages\PyCall\BD546\src\pyfncall.jl:43 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'AttributeError'>
...

Plotly:

using Plots
plotly()
plot(rand(3))
plot!(rand(5))

does not throw an error, plots one plot in the VScode pane, another in the browser.

inspectDR:

using Plots
inspectdr()
plot(rand(3))
plot!(rand(5))

Plots both plots in one VScode pane, but without signs of interactivity, AND in a separate window with a slider for scaling, freezes after a while. Warning message

(julia.exe:18584): Gtk-WARNING **: 22:17:40.298: Could not load a pixbuf from /org/gtk/libgtk/theme/Adwaita/assets/check-symbolic.svg.
This may indicate that pixbuf loaders or the mime database could not be found.

What interactive plotting works for you?

Plotly.jl and Plotlyjs.jl work fine for me, but also I don’t use VSCode so maybe that’s what’s screwing it up for you? I’ve never tried PyPlot or InspectDR.

Thats possible too, yes, or something to be fixed in the new 1.7.
I also tried PlotlyJS, et voila it is working!

using Plots
plotlyjs()
plot(rand(3))
plot!(rand(5))

Now 1 out of 4 working, I would not call this a solution.

Could you uncheck in VS Code settings “Julia: Use Plot Pane”, restart and try again with external plot windows? Using Julia 1.7 and everything seems to be working.

With Julia: Use Plot Pane unchecked and restarted:
plotlyjs: external window (Electron), interactive
plotly: in browser, interactive
pyplot: same vendor/Blas warning, no plot
inspectdr: own window, said slider (which is x-axis translation), no further useful interactivity.

Concerning InspectDR, please take a look at the keybindings section.

Concerning the pyplot back-end, the warning is present in my case too but pyplot does work fine. See if this post helps fixing your installation.

1 Like

Ok, a key-stroke interface, thx!

We do want you to get to the level 4 out of 4, it looks like you only have now one more to go. Bon courage!

1 Like

GLMakie with my Julia 1.7 is not working reliably. The zoom interaction is e.g. pressing x or y + mouse wheel. Crashes after a while.

julia> current_figure()
julia> yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyGLFWError (PLATFORM_ERROR): WGL: Failed to make context current: The requested transformation operation is not supported. 
Stacktrace:
 [1] _ErrorCallbackWrapper(code::Int32, description::Cstring)
   @ GLFW C:\Users\xxx\.julia\packages\GLFW\BWxfF\src\callback.jl:43