我正在尝试使用big data在plotly上围绕20 plots进行绘图,并将它们嵌入到web page中。我可以很好地使用username和在配置文件中找到的一个api_key绘制单独的图。
问题来了:我必须重新运行所有的20 plots与python program的时间间隔后,每个15 mins和每次我得到新的窗口。相反,我需要将相同的图绘制到update/redraw。
我该怎么做呢?我试着阅读了plot.ly文档和一些外部教程。找不到如何做这件事。谁可以帮助我的步骤或介绍给我一些文件,我可以知道如何使用多个绘图,将在同一时间更新。
我正在按照plotly tutorial中给出的步骤操作,我不确定是否应该使用stream_ids?或者我可以为每个图创建一个新的api_key?困惑!提前感谢您的建议。
编辑:我可以制作访问令牌,并从以下tutorial启动凭据。
下面的代码工作得很完美:但是现在我正在通过尝试最小化带有注释的代码来寻找以下代码中所需的修复,以及在哪里包含流API访问令牌,同时具有相当大的散点图?
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')发布于 2015-07-21 01:29:22
在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 urlhttps://stackoverflow.com/questions/31512714
复制相似问题