最近,我一直在使用 plotly 进行数据可视化。我已经创建了一个 plotly ,我需要制作一个新 plotly 。我创建了 2 个 Streaming API token 并将它们添加到凭据文件中。我不知道这些流式 token 实际上做了什么。我可以使用不同的流式传输 token 来流式传输不同的 plotly 吗?如果可以,请解释一下如何操作?我可以在多个跟踪上使用相同的流 token 吗?另外,我想知道在 plotly 中流式传输 token 的目的。
在 python 中进行流式传输:https://plot.ly/python/streaming-tutorial/
最初,我使用一个流式 API token 创建了一个图。现在,我想创建另一个单独的图。我需要确保新 plotly 不会覆盖第一个 plotly ,为此我认为可以使用流式 token ,尽管不完全确定。
请您参考如下方法:
只是为了向您展示呈现的工作流程here .它要求您在 Plotly 用户配置文件中设置两个不同的流。
stream_ids = tls.get_credentials_file()['stream_ids']
# Get stream id from stream id list
stream_id_1 = stream_ids[0]
stream_id_2 = stream_ids[1]
# Make instance of stream id object
stream_1 = go.Stream(
token=stream_id_1, # link stream id to 'token' key
maxpoints=80 # keep a max of 80 pts on screen
)
stream_2 = go.Stream(
token=stream_id_2, # link stream id to 'token' key
maxpoints=80 # keep a max of 80 pts on screen
)
# Initialize trace of streaming plot by embedding the unique stream_id
trace1 = go.Scatter(
x=[],
y=[],
mode='lines+markers',
stream=stream_1 # (!) embed stream id, 1 per trace
trace2 = go.Scatter(
x=[],
y=[],
mode='lines+markers',
stream=stream_2 # (!) embed stream id, 1 per trace
)
这应该可以为您完成工作。如前所述,有必要为您要显示的每个附加图使用附加流。
