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!
We recommend you read our Getting Started guide for the latest installation or upgrade instructions, then move on to our Plotly Fundamentals tutorials or dive straight in to some Basic Charts tutorials. A Choropleth Map is a map composed of colored polygons. It is used to represent spatial variations of a quantity.
A plotly.graph_objects.Scattergeo trace is a graph object in the figure's data list with any of the named arguments or attributes listed below. The data visualized as scatter point or lines on a geographic map is provided either by longitude/latitude pairs in `lon` and `lat` respectively or by geographic location IDs or names in `locations`.
New to Plotly? Plotly is a free and open-source graphing library for Python. We recommend you read our Getting Started guide for the latest installation or upgrade instructions, then move on to our Plotly Fundamentals tutorials or dive straight in to some Basic Charts tutorials. A Choropleth Map is a map composed of colored polygons.
The reason for my use of scattergeo is I'd like to plot a star symbol on top of the density mapbox, and the only symbol accepted via add_scattermapbox is a dot. If you choose the star symbol, there is no symbol added.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With