Show Sidebar Hide Sidebar

Mapbox Density Heatmap in Python

How to make a Mapbox Density Heatmap in Python with Plotly.

Mapbox Access Token

To plot on Mapbox maps with Plotly you may need a Mapbox account and a public Mapbox Access Token. See our Mapbox Map Layers documentation for more information.

Stamen Terrain base map: no token needed

In [1]:
import pandas as pd
quakes = pd.read_csv('')

import plotly.graph_objects as go
fig = go.Figure(go.Densitymapbox(lat=quakes.Latitude, lon=quakes.Longitude, z=quakes.Magnitude, radius=10))
fig.update_layout(mapbox_style="stamen-terrain", mapbox_center_lon=180)


See for more information about mapbox and their attribute options.