Clear a plot in the notebook

Hi all,

I’m using plot.ly 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",
        hoverinfo='name',
        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)'
            ),
        )

fig.data = [trace, trace1]
fig.layout = layout
iplot(fig)
    
for index, _files in enumerate(list_files_to_merge):
    
    _new_time = list_times[index]
    _new_T = list_temperature[index]
    
    trace1.x.append(_new_time)
    trace1.y.append(_new_T)

    iplot(fig)

Is there a way to clear the previous plot displayed?

thanks

Jean

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:

https://stackoverflow.com/questions/24816237/ipython-notebook-clear-cell-output-in-code