大数据多个图,多个网页Plotly

时间:2015-07-20 09:13:39

标签: python matplotlib plot plotly

我正在尝试使用big data 20 plots plotly上的web page进行投标,并将其嵌入username。我可以很好地绘制在个人资料中找到的api_key和一个20 plots的个别情节。

问题出现的时间是:我必须在每python program个间隔之后以15 mins重新运行所有update/redraw以及每次我获得新窗口时。相反,我需要与plot.ly相同的情节。

我该怎么做?我尝试阅读stream_ids文档以及外面的一些教程。找不到如何完成它。任何人都可以帮我一步,或者参考一些文件,我可以知道如何处理将同时更新的多个图。

我正在按照情节tutorial给出的步骤,不确定我是否应该使用api_key?或者我可以为每个情节创建一个新的import plotly.plotly as py import plotly.tools as tls from plotly.graph_objs import * import csv import pandas as pd import numpy as np df = pd.read_csv('finally.csv') df1=df[['NAME','COUNT']] sizemode='area' sizeref=df1['COUNT'].max()/1000 def Trace(X,PLACE,sizes): return Scatter( x=X['NAME'], y=X['COUNT'].sum(), name=PLACE, mode='marker', marker=Marker( line=Line(width=0.9), size=sizes, sizeref=sizeref, opacity=0.9, ) ) data=Data() for PLACE, X in df1.groupby('NAME'): sizes=X['COUNT'].sum()/1000 data.append(Trace(X,PLACE,sizes)) title = "Fig 1.1 : All NAMES" x_title = "Names".format() y_title = "Count" # Define a dictionary of axis style options axis_style = dict( zeroline=False, # remove thick zero line gridcolor='#FFFFFF', # white grid lines ticks='outside', # draw ticks outside axes ticklen=8, # tick length tickwidth=1.5 # and width ) # Make layout object layout = Layout( title=title, # set plot title plot_bgcolor='#EFECEA', # set plot color to grey xaxis=XAxis( axis_style, # add axis style dictionary title=x_title, # x-axis title ), yaxis=YAxis( axis_style, # add axis style dictionary title=y_title, # y-axis title ), showlegend=False, ) fig = Figure(data=data,layout=layout) plot_url=py.plot(fig,filename=' plotting') 吗?困惑!!!提前感谢您的建议。

编辑:我可以访问令牌并从以下tutorial启动凭据。

下面的代码非常完美:但是现在我正在寻找下面代码中所需的修复方法,尝试使用注释最小化代码以及在具有相当大的散点图时包含流API访问令牌的位置?

_id

1 个答案:

答案 0 :(得分:1)

plot/ iplot中有'fileopt'选项可以帮助您。例如,如果您想要为现有数据添加新跟踪,则可以运行

plot_url = py.plot(fig, filename='my-file', fileopt='append')

你是对的还没有很好的记录。但是如果你运行help(py.plot),你会得到一个小文件,如下所示:

plot(figure_or_data, validate=True, **plot_options)
Create a unique url for this plot in Plotly and optionally open url.

plot_options keyword agruments:
filename (string) -- the name that will be associated with this figure
fileopt ('new' | 'overwrite' | 'extend' | 'append') -- 'new' creates a
    'new': create a new, unique url for this plot
    'overwrite': overwrite the file associated with `filename` with this
    'extend': add additional numbers (data) to existing traces
    'append': add additional traces to existing data lists
world_readable (default=True) -- make this figure private/public
auto_open (default=True) -- Toggle browser options
    True: open this plot in a new browser tab
    False: do not open plot in the browser, but do return the unique url