如何使用子图生成图表工作室链接

发布于 2025-02-09 11:12:55 字数 1110 浏览 2 评论 0原文

我正在尝试在Python中构建DASH应用程序,该应用程序在Localhost:8050, 例如,这里有三个数字,它们与dcc.graph一起返回。

    def funct(data, x_data, y_data ):
        line_fig = px.line(x=x_data, y=y_data, title="Trend Line")
        indi_fig = go.Indicator(value = len(data), title='Total Count')
        bar_fig = go.Bar(x=x_data, y=y_data)
    return dcc.Grapgh(figure=line_fig), dcc.Grapgh(figure=indi_fig), 
                      dcc.Grapgh(figure=bar_fig)

但是,我想使用Chart Studio分享它, 在提供了用户名和API键之后,我希望该功能能够像下面一样起作用

    import chart_studio.plotly as py

    def funct(data, x_data, y_data ):
        line_fig = px.line(x=x_data, y=y_data, title="Trend Line")
        indi_fig = go.Indicator(value = len(data), title='Total Count')
        bar_fig = go.Bar(x=x_data, y=y_data)
        final_grid = [line_fig, indi_fig, bar_fig]
    return py.plot(final_grid, auto_open=True) #creates charts in plotly public repo

。如果我只通过一个无花果,我就可以成功运行它,例如,

    return py.plot(line_fig, auto_open=True)

我敢肯定我缺少一些重要的东西,但不确定是什么。 3个不同图表的原因只是自定义以及它们在浏览器中显示的方式。我没有在此处的代码中提到它。

I am trying to build a Dash application in python that prints out three charts on localhost:8050,
For example, here are three figures which are returned with dcc.Graph

    def funct(data, x_data, y_data ):
        line_fig = px.line(x=x_data, y=y_data, title="Trend Line")
        indi_fig = go.Indicator(value = len(data), title='Total Count')
        bar_fig = go.Bar(x=x_data, y=y_data)
    return dcc.Grapgh(figure=line_fig), dcc.Grapgh(figure=indi_fig), 
                      dcc.Grapgh(figure=bar_fig)

This works perfectly, however, I want to share it using chart studio,
after providing username and api key, I want the function to work like below

    import chart_studio.plotly as py

    def funct(data, x_data, y_data ):
        line_fig = px.line(x=x_data, y=y_data, title="Trend Line")
        indi_fig = go.Indicator(value = len(data), title='Total Count')
        bar_fig = go.Bar(x=x_data, y=y_data)
        final_grid = [line_fig, indi_fig, bar_fig]
    return py.plot(final_grid, auto_open=True) #creates charts in plotly public repo

This doesn't work though. I am able to successfully run it if I pass only one fig, for eg.,

    return py.plot(line_fig, auto_open=True)

I'm sure I'm missing something important, but not sure what. The reason for 3 different charts is just customization and the way they are displayed in browser. I have not mentioned it in the code here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文