Plotly: cartes choroplèthes et scattergeo
objectif
Expliquer et montrer comment afficher des données géospatiales interactives.
code minimal
import plotly.express as px
df = px.data.gapminder().query("year == 2007")
fig = px.choropleth(df, locations="iso_alpha", color="lifeExp", hover_name="country")
# fig.show()
utilisation
# scattergeo
# fig2 = px.scatter_geo(df, locations="iso_alpha", color="continent", size="pop")
variante(s) utile(s)
# Mapbox nécessite un token
# px.set_mapbox_access_token("...")
notes
- Plotly permet l’export en HTML autonome.
- Les cartes nécessitent parfois des clés (Mapbox).