Clear a plot in the notebook

Hi all,

I’m using offline in the notebook. I’m plotting a char (see screenshot) and using a loop, I plot one by one the red dot on top of it. Using the following code, I get a new plot added to the bottom of the previous plot for each loop.

list_times_done = []
list_temperature_done = []

fig = go.Figure()

trace = go.Scatter(
        x = list_times,
        y = list_temperature,
        mode = 'lines+markers',
        name="Rebinned Files",
        line = dict(
            shape = 'hvh'),

trace1 = go.Scatter(
        x = [],
        y = [],
        mode = 'markers',
        marker = dict(
            size = 20,
            color = 'rgba(255,0,0,0.5)'

layout = go.Layout(
        title = 'Progress of Rebinned File Created',
        xaxis = dict(
            title = 'Time (span)'
        yaxis = dict(
            title = 'Temperature (C)'
        ) = [trace, trace1]
fig.layout = layout
for index, _files in enumerate(list_files_to_merge):
    _new_time = list_times[index]
    _new_T = list_temperature[index]


Is there a way to clear the previous plot displayed?



Looks like I’m the only one interested by this but I found the way to do it using matplotlib, still unable to do it with plotly ! Let me know if you are interested by the answer and I will post it but because it’s only matplotlib, this is the wrong place to do it

Here is your solution: