Show Sidebar Hide Sidebar

Mapbox Density in R

How to make a Mapbox Density Heatmap in R

New to Plotly?

Plotly's R library is free and open source!
Get started by downloading the client and reading the primer.
You can set up Plotly to work in online or offline mode.
We also have a quick-reference cheatsheet (new!) to help you get started!

Version Check

Version 4 of Plotly's R package is now available!
Check out this post for more information on breaking changes and new features available in this version.

## [1] ''

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 Tile, no Token Needed


quakes = read.csv('')

p <- quakes %>%
    type = 'densitymapbox',
    lat = ~Latitude,
    lon = ~Longitude,
    coloraxis = 'coloraxis',
    radius = 10) %>%
    mapbox = list(
      center= list(lon=180)), coloraxis = list(colorscale = "Viridis"))

# Create a shareable link to your chart
# Set up API credentials:
chart_link = api_create(p, filename="density-with-token")


See for more information and options!