import plotly.plotly as py
import plotly.graph_objs as go
py.sign_in('Marion', '2qdyfjyr7o') # plotly网站的用户名和API
trace = go.Bar(x=[2, 4, 6], y= [10, 12, 15])
data = [trace]
layout = go.Layout(title='A Simple Plot', width=800, height=640)
fig = go.Figure(data=data, layout=layout)
py.plot(fig, filename="a-simple-plot")
# py.image.save_as(fig, filename='a-simple-plot.png')
import plotly.offline as py
import plotly.graph_objs as go
trace = go.Box(
x=[1, 2, 3, 4, 5, 6, 7]
)
data = [trace]
py.plot(data) # 离线方式使用:offline