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?
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.
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.
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.
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