What is the best practice plotting workflow in julia?

Hi, don’t know if this is a duplicated question.

Using Makie.jl to plot in Julia has been a wonderful experience. But I’m wondering if there is a more convenient way to plot like using Matplotlib in python? In plotting there’s always plenty of work on frequently changing linewidth, color, etc. It is a bit unconvenient since in Pluto, the fig=Figure() code should be re-run after each approach (don’t quite understand how Pluto deals with the cell execution logic here) to avoid duplicated lines on the same figure. In python, I simply use a JupyterNotebook and change can be applied to the figure object, pretty fast and convenient.

Is there a best practice for plotting in Julia’s ecosystem? I mean I want a interactive environment like the awesome Pluto.jl. Also I would like figures being fast updated.

or wrap up

begin
    fig =Figure()
    ax = Axis(fig[1,1])
    lines!(ax,...)

in a single cell is an ideal enough solution? Not so sure. Thanks for any comment!

Pluto does not track mutations to variables, just assignments. So if you define fig in one cell and do Axis(fig[1, 1]) in another, then Pluto doesn’t know that this mutates fig, and if the second cell is changed, it will run multiple times against the same figure.

That’s why you’re on the right track with the begin block, you wrap the whole cell making a single figure in one block and if you change anything, the figure is recreated. Unless you plot huge amounts of data, recreating a Figure should be pretty fast, on the order of milliseconds.

In Makie itself, you can of course also make changes to an existing plot and see the changes immediately with WGLMakie or GLMakie, but Pluto itself is not geared towards that workflow.

6 Likes

It’s worth noting that you don’t have to use Pluto when its execution model isn’t what you want. You can just use Jupyter with IJulia. IJulia also works well from VSCode.

1 Like

thanks! I think I’ve tried jupyter but have run into some constantly compiling issue. Anyway I’ll check again.

Hard to tell if it’s the same issue, but I’ve had similar problems and found that completely removing and re-installing the Julia kernel helped in my case.