0

我正在big data尝试在. 我可以很好地绘制在配置文件中找到的单个图。20 plotsplotlyweb pageusernameapi_key

问题来了:我必须在每次获得新窗口时20 plots重新运行所有python program间隔。15 mins相反,我需要相同的情节update/redraw

我怎么得到它?我尝试阅读plot.ly 文档以及外面的一些教程。找不到如何完成它。任何人都可以帮助我完成步骤或让我参考一些文档,我可以在其中知道如何处理将同时更新的多个绘图。

我正在按照情节教程中给出的步骤不确定是否应该使用stream_ids?或者我可以api_key为每个情节创建一个新的吗?困惑!提前感谢您的建议。

编辑:我可以从以下教程中制作访问令牌并启动凭据。

下面的代码完美无缺:但是现在我正在通过尝试最小化带有注释的代码以及在具有相当大的散点图的同时包含流式 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')
4

1 回答 1

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
于 2015-07-20T17:29:22.393 回答