简体   繁体   中英

Plotly Chloropleth combined with ScatterGeo

Can anyone help me spot the error here?

fig = go.Figure()

fig.add_trace(
    go.Choroplethmapbox(
        geojson=counties,
        locations=df_se['FIPS'], z=df_se['use_values'],
        colorscale="Viridis", zmin=min(df_se['use_values']), zmax=max(df_se['use_values']),
        marker_opacity=0.5, marker_line_width=0
    ))

fig.add_trace(
    go.Scattergeo(
        lon = df_jake['lng'],
        lat = df_jake['lat'],
        text = df_jake['Name']+', '+df_jake['Link'],
        mode = 'markers'
    ))
fig.update_layout()
fig.show()

It just shows up blank. I can plot Chloropleth and ScatterGeo seperately however

Thanks!

A bit of context: Choroplethmapbox makes choropleths on tile maps ( example ), whereas Scattergeo makes points on outline maps ( example ).

The scatter counterpart to Choroplethmapbox is Scattermapbox ( example ) and the choropleth counterpart to Scattergeo is Choropleth ( example ).

So the answer likely depends on what you are trying to do: if you're trying to show a choropleth and scatter data on a tile map, you'll want to switch from Scattergeo to Scattermapbox and if you want to show this data on an outline map, you'll want to switch from Choroplethmapbox to Choropleth .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM