Skip to content

Commit d739f6d

Browse files
committed
basic cluster example
1 parent d94d667 commit d739f6d

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

doc/python/scattermapbox.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ jupyter:
55
text_representation:
66
extension: .md
77
format_name: markdown
8-
format_version: '1.2'
9-
jupytext_version: 1.4.2
8+
format_version: '1.3'
9+
jupytext_version: 1.14.1
1010
kernelspec:
11-
display_name: Python 3
11+
display_name: Python 3 (ipykernel)
1212
language: python
1313
name: python3
1414
language_info:
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.7.7
23+
version: 3.8.0
2424
plotly:
2525
description: How to make scatter plots on Mapbox maps in Python.
2626
display_as: maps
@@ -245,6 +245,28 @@ fig.update_layout(
245245
fig.show()
246246
```
247247

248+
#### Add Clusters
249+
250+
*New in 5.11*
251+
252+
Display clusters of data points by setting `cluster`. Here, we enable it with `enabled=True`. Other properties available on `cluster` include `color` (for setting the color of the clusters), `size` (for setting the size of a cluster step), and `step` (for configuring how many points it takes to create a cluster or advance to the next cluster step.
253+
254+
255+
```python
256+
import plotly.express as px
257+
import pandas as pd
258+
259+
px.set_mapbox_access_token(open(".mapbox_token").read())
260+
261+
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_february_us_airport_traffic.csv')
262+
263+
fig = px.scatter_mapbox(df, lat="lat", lon="long", size="cnt", zoom=3)
264+
265+
fig.update_traces(cluster=dict(enabled=True))
266+
267+
fig.show()
268+
```
269+
248270
#### Reference
249271

250272
See [function reference for `px.(scatter_mapbox)`](https://plotly.com/python-api-reference/generated/plotly.express.scatter_mapbox) or https://plotly.com/python/reference/scattermapbox/ for more information and options!

0 commit comments

Comments
 (0)