6

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!

Derek O
  • 16,770
  • 4
  • 24
  • 43
mustacheMcGee
  • 481
  • 6
  • 19

1 Answers1

4

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.

nicolaskruchten
  • 26,384
  • 8
  • 83
  • 101
  • 1
    I still cannot figure out a way to overlay a `go.Scattergeo()` using `.shp` json using the geojson argument and overlay that with longitudes and latitudes of say, stores, using the arguments `lon` andl `lat` under the same function. All three of these arguments are available and the execution does not trigger any exceptions. Just like @mustacheMcGee said I can produce two separate map plots but the combination does not work. – hussam Dec 04 '20 at 00:31