Updating a chart with a plot offline with python

I am using plotly offline on Jupyter. I draw curves:

from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
from plotly.graph_objs import *
import datetime as dt

list_date = [dt.datetime(2016,1,1).date(), dt.datetime(2016,1,2).date(), dt.datetime(2016,1,3).date(), dt.datetime(2016,1,4).date()]
data = []
for i in range(3) : 
    list = [i/2+1, i/2+2, i/2+3, i/2+4]
    data.append(Scatter(x=list_date, y=list, name='y'+str(i)))
figure = Figure(data=data)
iplot(figure)

And I get a very good schedule! The last user wants to add a histogram to it (in addition to the already existing two lines).

list_bar = [0.5, 1.5, 2.5, 3.5]
data = [Bar(x=list_date, y=list_bar, name='bar')]previ
figure.update(data=data)
iplot(figure)

But I only have a histogram, not the previous 2 lines. How to disable offline file foption fileopt = 'append' ??

py.plot(data, filename='append plot', fileopt='append') 

Thank!

+4
source share

Source: https://habr.com/ru/post/1664193/


All Articles