首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >plotly中的流式API令牌是什么?

plotly中的流式API令牌是什么?
EN

Stack Overflow用户
提问于 2019-04-02 01:37:24
回答 1查看 277关注 0票数 2

最近,我一直在使用plotly进行数据可视化。我已经创建了一个图,我需要创建一个新的图。我已经创建了2个流式API令牌,并将它们添加到凭据文件中。我不知道这些流令牌到底是做什么的。我可以使用不同的流式标记来流式传输不同的情节吗?如果可以,请解释如何使用?我可以在多个跟踪上使用相同的流令牌吗?此外,我想知道在情节中流式令牌的目的。

plotly in python:https://plot.ly/python/streaming-tutorial/

最初,我使用一个流式API令牌创建了一个绘图。现在,我想创建另一个单独的图。我需要确保新的plot不会覆盖first plot,为此,我认为可以使用流式标记,尽管不能完全确定。

EN

回答 1

Stack Overflow用户

发布于 2019-04-02 21:45:58

只是为了向你展示一下here展示的工作流程。它要求您在Plotly用户配置文件中设置两个不同的流。

代码语言:javascript
运行
复制
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
)

这将为您做好准备。如前所述,对于您想要显示的每个附加绘图,有必要使用一个additionall流。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55460710

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档