【问题标题】:How to get Dash to work with a Choropleth Plotly graph如何让 Dash 使用 Choropleth Plotly 图
【发布时间】:2021-07-11 19:36:52
【问题描述】:

我正在尝试使用 Dash 显示 Ploty 等值线地图。我尝试在 anaconda 提示符中使用 conda update --all 和 conda update dash 更新 Dash 和 Plotly,但这并没有解决问题。下面是代码为fig.show() 代码和 Dash 代码生成的图像的链接。

虚线绘图不起作用:

下面是代码:

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)


fig = px.choropleth(dt_rwly_stn, geojson=smh, color="ConfirmedCovidCases",
                    locations="CountyName", featureidkey="properties.CountyName",
                    projection="mercator",
                    color_continuous_scale= 'Reds',
                   )
fig.update_geos(fitbounds="locations", visible=False)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show() 

app.layout = html.Div(children=[
    html.H1(children='My First Dash'),

    html.Div(children='''
        Dash: A web application framework for Python.
    '''),

    dcc.Graph(
        id='example-graph1',
        figure=fig
    ),
])
                 
    
if __name__ == '__main__':
    app.run_server(debug=True, use_reloader=False)

谁能帮助我使用 Dash 正确显示 Plotly 图形?

【问题讨论】:

    标签: python plotly plotly-dash


    【解决方案1】:

    我解决了这个问题。我不得不卸载 Anaconda,因为我的基础环境中安装了太多冲突的软件包。当我重新安装它时,我创建了一个新环境并只安装了我需要的软件包(即 conda install -c conda-forge dash 和 conda install -c conda-forge plotly 。现在有问题的代码可以完美运行。

    Dash Plotly Working

    【讨论】:

      猜你喜欢
      • 2022-09-29
      • 2021-12-01
      • 1970-01-01
      • 2021-08-02
      • 1970-01-01
      • 1970-01-01
      • 2020-11-09
      • 2021-08-26
      • 2019-07-16
      相关资源
      最近更新 更多