<tfoot id='BpBWC'></tfoot>

          <bdo id='BpBWC'></bdo><ul id='BpBWC'></ul>
      1. <legend id='BpBWC'><style id='BpBWC'><dir id='BpBWC'><q id='BpBWC'></q></dir></style></legend>
      2. <i id='BpBWC'><tr id='BpBWC'><dt id='BpBWC'><q id='BpBWC'><span id='BpBWC'><b id='BpBWC'><form id='BpBWC'><ins id='BpBWC'></ins><ul id='BpBWC'></ul><sub id='BpBWC'></sub></form><legend id='BpBWC'></legend><bdo id='BpBWC'><pre id='BpBWC'><center id='BpBWC'></center></pre></bdo></b><th id='BpBWC'></th></span></q></dt></tr></i><div id='BpBWC'><tfoot id='BpBWC'></tfoot><dl id='BpBWC'><fieldset id='BpBWC'></fieldset></dl></div>

        <small id='BpBWC'></small><noframes id='BpBWC'>

        Plotly:如何重写标准仪表板应用程序以在 JupyterLab 中启动它?

        Plotly: How to rewrite a standard dash app to launch it in JupyterLab?(Plotly:如何重写标准仪表板应用程序以在 JupyterLab 中启动它?)
      3. <tfoot id='nVYSK'></tfoot>
        • <small id='nVYSK'></small><noframes id='nVYSK'>

              • <legend id='nVYSK'><style id='nVYSK'><dir id='nVYSK'><q id='nVYSK'></q></dir></style></legend>
                  <bdo id='nVYSK'></bdo><ul id='nVYSK'></ul>

                    <tbody id='nVYSK'></tbody>

                  <i id='nVYSK'><tr id='nVYSK'><dt id='nVYSK'><q id='nVYSK'><span id='nVYSK'><b id='nVYSK'><form id='nVYSK'><ins id='nVYSK'></ins><ul id='nVYSK'></ul><sub id='nVYSK'></sub></form><legend id='nVYSK'></legend><bdo id='nVYSK'><pre id='nVYSK'><center id='nVYSK'></center></pre></bdo></b><th id='nVYSK'></th></span></q></dt></tr></i><div id='nVYSK'><tfoot id='nVYSK'></tfoot><dl id='nVYSK'><fieldset id='nVYSK'></fieldset></dl></div>
                  本文介绍了Plotly:如何重写标准仪表板应用程序以在 JupyterLab 中启动它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  您可以在 plotly 文档中找到一堆 Dash 示例,并且大多数示例都以关于如何使用 Dash 构建图形的说明结尾:

                  <块引用>

                  达世币呢?Dash 是一个用于构建的开源框架分析应用程序,无需 Javascript,它是与 Plotly 图形库紧密集成.

                  但您也可以使用 mode='external' 来启动 Dash 它自己的标签:

                  您可以设置 mode='external' 在默认浏览器中启动它.

                  包含更改的完整代码:'

                  导入 plotly.graph_objects将 plotly.express 导入为 px# 导入破折号从 jupyter_dash 导入 JupyterDash将 dash_core_components 导入为 dcc将 dash_html_components 导入为 html# 数据和绘图图df = px.data.gapminder().query("country=='Canada'")fig = px.line(df, x="year", y="lifeExp", title='加拿大的预期寿命')# 设置 Dash 应用程序# app = dash.Dash()应用程序 = JupyterDash(__name__)app.layout = html.Div([dcc.Graph(图=图)])# 启动 Dash 应用程序# app.run_server(debug=True,# use_reloader=False # 如果在 Jupyter 内部,则关闭重新加载器# )app.run_server(mode='inline', 端口 = 8070, dev_tools_ui=True,dev_tools_hot_reload =真,线程=真)

                  You can find a bunch of Dash examples in the plotly docs, and most examples end with a note on how to build figures using Dash:

                  What About Dash? Dash is an open-source framework for building analytical applications, with no Javascript required, and it is tightly integrated with the Plotly graphing library.

                  Learn about how to install Dash at https://dash.plot.ly/installation.

                  But I'd like to fire them up in JupyterLab instead. So what changes would I have to make in the following 'normal' Dash app to make it run in JupyterLab?

                  Code sample:

                  import plotly.graph_objects as go
                  import plotly.express as px
                  import dash
                  import dash_core_components as dcc
                  import dash_html_components as html
                  
                  # data and plotly figure
                  df = px.data.gapminder().query("country=='Canada'")
                  fig = px.line(df, x="year", y="lifeExp", title='Life expectancy in Canada')
                  
                  # Set up Dash app
                  app = dash.Dash()
                  app.layout = html.Div([
                      dcc.Graph(figure=fig)
                  ])
                  
                  # Launch Dash app
                  app.run_server(debug=True,
                                 use_reloader=False # Turn off reloader if inside Jupyter
                                ) 
                  

                  解决方案

                  Any working Dash app can be launched from JupyterLab with the setup described in the question by specifying use_reloader=False in:

                  app.run_server(debug=True,
                             use_reloader=False # Turn off reloader if inside Jupyter
                            ) 
                  

                  But if you'd like to use JupyterLab and select between launching the app in your default browser, inline in a cell or directly in Jupyter in its own tab, just follow these simple steps:

                  Change the following lines

                  # 1
                  import dash
                  
                  # 2
                  app = dash.Dash()
                  
                  # 3
                  app.run_server(debug=True,
                             use_reloader=False # Turn off reloader if inside Jupyter
                            )  
                  

                  To this:

                  # 1
                  from jupyter_dash import JupyterDash
                  
                  # 2
                  app = JupyterDash(__name__)
                  
                  # 3
                  app.run_server(mode='inline', port = 8070, dev_tools_ui=True,
                            dev_tools_hot_reload =True, threaded=True)
                  

                  This will launch Dash inline directly in JupyterLab:

                  But you can also go for mode='external' to launch Dash it its own tab:

                  And you can set mode='external' to launch it in your default browser.

                  Complete code with changes:'

                  import plotly.graph_objects as go
                  import plotly.express as px
                  # import dash 
                  from jupyter_dash import JupyterDash
                  
                  import dash_core_components as dcc
                  import dash_html_components as html
                  
                  # data and plotly figure
                  df = px.data.gapminder().query("country=='Canada'")
                  fig = px.line(df, x="year", y="lifeExp", title='Life expectancy in Canada')
                  
                  # Set up Dash app
                  # app = dash.Dash()
                  
                  app = JupyterDash(__name__)
                  
                  app.layout = html.Div([
                      dcc.Graph(figure=fig)
                  ])
                  
                  # Launch Dash app
                  # app.run_server(debug=True,
                  #                use_reloader=False # Turn off reloader if inside Jupyter
                  #               )
                  
                  app.run_server(mode='inline', port = 8070, dev_tools_ui=True,
                            dev_tools_hot_reload =True, threaded=True)
                  

                  这篇关于Plotly:如何重写标准仪表板应用程序以在 JupyterLab 中启动它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                  Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                  python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                  Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                  How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                  Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)

                    <i id='33IOr'><tr id='33IOr'><dt id='33IOr'><q id='33IOr'><span id='33IOr'><b id='33IOr'><form id='33IOr'><ins id='33IOr'></ins><ul id='33IOr'></ul><sub id='33IOr'></sub></form><legend id='33IOr'></legend><bdo id='33IOr'><pre id='33IOr'><center id='33IOr'></center></pre></bdo></b><th id='33IOr'></th></span></q></dt></tr></i><div id='33IOr'><tfoot id='33IOr'></tfoot><dl id='33IOr'><fieldset id='33IOr'></fieldset></dl></div>
                        <tbody id='33IOr'></tbody>
                    1. <legend id='33IOr'><style id='33IOr'><dir id='33IOr'><q id='33IOr'></q></dir></style></legend>

                      <small id='33IOr'></small><noframes id='33IOr'>

                          <bdo id='33IOr'></bdo><ul id='33IOr'></ul>
                            <tfoot id='33IOr'></tfoot>