I am trying to draw a canvas in Jupyter Labs, refreshing it in a loop on user input (in the example I use wait). I understand it does not work due to GUI and lack of multithreading, however, is there a way to do it, or am I stuck with matplotlib?
This is the example code that draws only after the loop is finished:
import numpy as np
from time import sleep
c = ROOT.TCanvas()
for i in range(3):
x = np.arange(10).astype(np.float64)
y = np.random.rand(10).astype(np.float64)
g = ROOT.TGraph(len(x), x, y)
I think @etejedor might know.
In a notebook, canvases are drawn only at cell completion (it’s a post-process of the cell), so unfortunately there’s no live display of the changes in a canvas.
But is it a limitation of ROOT? I found a way how it can be done with matplotlib:
import pylab as pl
from IPython import display
for i in range(10):
It’s not a limitation of ROOT per se, but of the current implementation. We could create some kind of widget for the notebook which is able to get updated data from the server side and display it right away.
We actually want to implement this in the context of a distributed execution with RDataFrame from a notebook, since distributed computations can take time and it would be good to have some live feedback of e.g. some histogram that is being generated. But this is still not implemented.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.