Hello,
is it possible to redraw TCanvas in the same Jupyter cell (replace the previously drawn plot with the new one)?
The following standalone example demonstrates my goal:
import ROOT
import ipywidgets as widgets
ROOT.gStyle.SetOptStat(0)
slider = widgets.IntSlider(description='Bins', min=3, max=100, step=1, value=30, layout=widgets.Layout(width='50%'))
c1 = ROOT.TCanvas("c1", "Example")
c1.Draw()
@widgets.interact(bins=slider)
def plot_interactively(bins: int):
# I thought this would delete the objects inside the canvas, but no
c1.Clear()
h1 = ROOT.TH1F("h1", "h1", bins, 0, 5)
h1.Fill(1)
h1.Fill(2)
h1.Fill(3)
h1.Fill(1)
h1.Fill(2)
h1.Fill(1)
h1.DrawClone()
# c1.Draw() # This command will display the updated canvas, but as new. The old one stays there as well.
With each change, I would like to replace the existing plot with a new one.
Thank you for your help.
Regards,
Ladislav