首页 > 解决方案 > plotly dash不刷新

问题描述

我是 plotly 和 dash 的新手 我有一些问题:我收到了这条消息:Serving Flask app "dash" (lazy loading)

此外,除非我重新启动计算机或更改 app.run_server() 中的端口,否则我插入 Web 结果的网页会显示原始图形,这是我的代码:

import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go
import numpy as np

app = dash.Dash()

np.random.seed(42)
random_x = np.random.randint(1,101,100)
random_y = np.random.randint(1,101,100)

app.layout = html.Div([
    dcc.Graph(
        id='scatter3',
        figure={
            'data': [
                go.Scatter(
                    x = random_x,
                    y = random_y,
                    mode = 'markers',
                    marker = {
                        'size': 12,
                        'color': 'rgb(51,204,153)',
                        'symbol': 'pentagon',
                        'line': {'width': 2}
                        }
                )
            ],
            'layout': go.Layout(
                title = 'Random Data Scatterplot',
                xaxis = {'title': 'Some random x-values'},
                yaxis = {'title': 'Some random y-values'},
                hovermode='closest'
            )
        }
    )
])

if __name__ == '__main__':
    app.run_server()

标签: pythonplotlyplotly-dash

解决方案


将最后一行更改为app.run_server(debug=True).


推荐阅读