Using Makie with Revise

Hi - is there a workflow that helps with incrementally building a graph with Makie?
At the moment, I am having to restart the REPL when making large changes to my scene (changing a barplot to a line for example). The compile time makes it impossible to quickly iterate.

I can get revise to spot function changes as per the examples, but changing a colour variable, or adding a new Makie scene doesn’t have an effect on the graph until restarting.

Thanks!

Do you use includet ? Is your function part of a project ?

Yes, using includet will update any functions. But newly declared or changed variables aren’t picked up. I have to manually redefine my scene in the REPL to get it to update ( at least that way there’s no need to recompile!)

How do you mean by the project part? I have a folder full of scripts at the moment, and I’m activating that folder as a project in pkg yes.

You’re doing something wrong if you have to restart for changed plotting functions… I’m not sure what exactly you’re doing, but Makie is really no different from any other package in terms of running changed code with revise. And it sounds like you’re not making changes to library code, just your own right? I’m just wondering because your title is Makie specific, but your problem seems not to be Makie related

Maybe you can give a more concrete example of your workflow, so we might find where the problem is

1 Like

Hi Jules,

That’s right, I’m changing my own code. I chose that title in case someone had been through a similar issue with it. I wasn’t sure where the issue stems from, just my current use case. :slightly_smiling_face:

I’ll outline what I’ve done / been doing -

  • Revise, then OhMyREPL in startup.jl. I’ve also set it to activate the project in open directory automatically.
  • Running Julia in VSCode, on OS X
  • adapting the Makie tutorial code:
using GLMakie
col = :red
xs = Node([2,2])
ys =  Node(Node[2,3])
scene2 = barplot(xs, ys, color = col)
display(scene2)

Adding or changing variables in my file won’t show in the REPL. If I change the array literals ‘yx’ or ‘ys’ and hit save, they don’t update their value or the graph. Same for col

Functions as I said will update so Revise does seem to be working. Though you’re right that the issue seems to be stemming from that rather than Makie, or I’m misunderstanding what Revise is able to spot.

There’s not much else going on in terms of workflow, only just started it.

I found the answer in the Revise docs . Rather confusingly, includet() doesn’t track variable changes by default.
Adding __revise_mode__ = :eval will enable it.
Will test it out with Makie shortly, but that should solve it.

2 Likes

You should put everything inside a function. If the function is inside a “revised” module then all change will be taken into account.
toto

2 Likes

I will prepare a video to show a standard workflow using Revise in a project.
I did prepare this one https://www.youtube.com/watch?v=BLcNv_f75kI but it is in french… excuse my french !

6 Likes

Cool ! I was not aware of this.

That would be really helpful. Yes most things should be in functions anyway but for a quick throwaway test the standard behaviour is puzzling to begin with! Thanks for your help.

Okay so I’m still having an issue getting live updates. Revise will change the variables now.

But either directly editing the Node([x,y]) definitions or updating them using node[]=[x,y] still doesn’t show a change in the graph? Still the same problem for editing static values like col for example. I have to re-run the line defining the graph scene again to show the change.

Same issue happens if the code is inside a function.

Am I missing something obvious? Or is that expected behaviour?

I am afraid I do not understand your workflow.
Maybe a MWE could help…

I’m simply running a script using includet() from command line. I can soldier on and keep calling the graphing function manually for now.

Why don’t you just reinclude the file that does the actual drawing? Put serious functions in a package and let Revise handle those, but just reexecute your plotting commands each time you want to regenerate the plot.

Revise is targeted at code, but you’re trying to get it to work on data. That’s a different task and one that you should instead be using Observables for.

6 Likes

If you include code again where an observable is defined, and change the value, if revise runs that again you have a new observable and your plot will still look the same. If you want the plot to change you have to mutate the exact observables that are connected to it. But if you’re just iteratively building a plot that’s not the use case for observables. It should really not take long to just return a new scene again and again.

3 Likes

Thanks guys, yeah I think I was moving the goalposts a little! Not too much effort to hit ↑ ⏎ in terminal.