在没有在线 plotly 帐户的情况下使用 plotly

Using plotly without online plotly account

是否可以在没有在线 plotly 帐户的情况下使用 plotly 库在 python 中创建图表?我认为代码是开源的 https://github.com/plotly/plotly.py。我想知道我们是否可以在没有在线帐户的情况下使用它。

是的,可以做到。拥有 plotly 帐户的唯一目的是在您的 plotly 帐户中托管图表。

Plotly Offline 允许您离线创建图表并保存在本地。您的数据和图表将保留在本地系统中,而不是将图表保存到服务器。

无需plotly账号即可离线工作。 剧情版本应为1.9.x系列或更高版本。

import numpy as np
from plotly import __version__
from plotly.offline import download_plotlyjs, init_notebook_mode, plot,iplot
print (__version__) # requires version >= 1.9.0

#Always run this the command before at the start of notebook
init_notebook_mode(connected=True)
import plotly.graph_objs as go

x=np.array([2,5,8,0,2,-8,4,3,1])
y=np.array([2,5,8,0,2,-8,4,3,1])


data = [go.Scatter(x=x,y=y)]
fig = go.Figure(data = data,layout = go.Layout(title='Offline Plotly Testing',width = 800,height = 500,
                                           xaxis = dict(title = 'X-axis'), yaxis = dict(title = 'Y-axis')))


plot(fig,show_link = False)

您的离线 plotly 库已设置。 参考:Plotly Offline Tutorial

This the offline graph that is created and you check the there is no online url because the graph is stored in local directory

离线包非常适合非订阅用户,但图形质量明显低于在线版本。如果您想保存图形并与他人分享,这可能会成为问题。

您可以使用:

import plotly
plotly.offline.init_notebook_mode(connected=True)

离线使用 Plotly。