Skip to content

Commit 3b581e6

Browse files
committed
various updates for new map traces
1 parent 2e0f184 commit 3b581e6

15 files changed

+86
-91
lines changed

doc/python/axes.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Other kinds of subplots and axes are described in other tutorials:
4141
- [Polar axes](/python/polar-chart/). The axis object is [`go.layout.Polar`](/python/reference/layout/polar/)
4242
- [Ternary axes](/python/ternary-plots). The axis object is [`go.layout.Ternary`](/python/reference/layout/ternary/)
4343
- [Geo axes](/python/map-configuration/). The axis object is [`go.layout.Geo`](/python/reference/layout/geo/)
44-
- [Mapbox axes](/python/mapbox-layers/). The axis object is [`go.layout.Mapbox`](/python/reference/layout/mapbox/)
44+
- [Map axes](/python/map-layers/). The axis object is [`go.layout.Map`](/python/reference/layout/map/)
4545
- [Color axes](/python/colorscales/). The axis object is [`go.layout.Coloraxis`](/python/reference/layout/coloraxis/).
4646

4747
**See also** the tutorials on [facet plots](/python/facet-plots/), [subplots](/python/subplots) and [multiple axes](/python/multiple-axes/).
@@ -453,10 +453,10 @@ fig.show()
453453
*New in 5.23*
454454

455455
You can adjust tick label positions by moving them a number of pixels away from the axis using `ticklabelstandoff` or along the axis using `ticklabelshift`.
456-
456+
457457
In this example, `ticklabelshift=25` shifts the labels 25 pixels to the right along the x-axis. By providing a negative value, we could move the labels 25 pixels to the left, (`ticklabelshift=-25`).
458458

459-
Here, `ticklabelstandoff=15` moves the labels further 15 pixels away from the x-axis. A negative value here would move them close to the axis.
459+
Here, `ticklabelstandoff=15` moves the labels further 15 pixels away from the x-axis. A negative value here would move them close to the axis.
460460

461461
```python
462462
import plotly.express as px
@@ -483,7 +483,7 @@ fig.show()
483483

484484
On date or linear axes, use `ticklabelindex` to draw a label for a minor tick instead of a major tick.
485485

486-
To draw the label for the minor tick before each major tick, set `ticklabelindex` -1, like in the following example.
486+
To draw the label for the minor tick before each major tick, set `ticklabelindex` -1, like in the following example.
487487

488488
```python
489489
import plotly.express as px

doc/python/bubble-maps.md

+4-4
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.1'
9-
jupytext_version: 1.1.1
8+
format_version: '1.3'
9+
jupytext_version: 1.16.3
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.6.7
23+
version: 3.10.0
2424
plotly:
2525
description: How to make bubble maps in Python with Plotly.
2626
display_as: maps

doc/python/choropleth-maps.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jupyter:
3333
thumbnail: thumbnail/choropleth.jpg
3434
---
3535

36-
A [Choropleth Map](https://en.wikipedia.org/wiki/Choropleth_map) is a map composed of colored polygons. It is used to represent spatial variations of a quantity. This page documents how to build **outline** choropleth maps, but you can also build [choropleth **tile maps**](/python/mapbox-county-choropleth).
36+
A [Choropleth Map](https://en.wikipedia.org/wiki/Choropleth_map) is a map composed of colored polygons. It is used to represent spatial variations of a quantity. This page documents how to build **outline** choropleth maps, but you can also build [choropleth **tile maps**](/python/tile-county-choropleth).
3737

3838
Below we show how to create Choropleth Maps using either Plotly Express' `px.choropleth` function or the lower-level `go.Choropleth` graph object.
3939

doc/python/county-choropleth.md

+6-6
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.3.1
8+
format_version: '1.3'
9+
jupytext_version: 1.16.3
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.6.8
23+
version: 3.10.0
2424
plotly:
2525
description: How to create colormaped representations of USA counties by FIPS
2626
values in Python.
@@ -37,7 +37,7 @@ jupyter:
3737
### Deprecation warning
3838

3939

40-
This page describes a [legacy "figure factory" method](/python/figure-factories/) for creating map-like figures using [self-filled scatter traces](/python/shapes). **This is no longer the recommended way to make county-level choropleth maps**, instead we recommend using a [GeoJSON-based approach to making outline choropleth maps](/python/choropleth-maps/) or the alternative [Mapbox tile-based choropleth maps](/python/mapbox-county-choropleth).
40+
This page describes a [legacy "figure factory" method](/python/figure-factories/) for creating map-like figures using [self-filled scatter traces](/python/shapes). **This is no longer the recommended way to make county-level choropleth maps**, instead we recommend using a [GeoJSON-based approach to making outline choropleth maps](/python/choropleth-maps/) or the alternative [tile-based choropleth maps](/python/tile-county-choropleth).
4141

4242

4343
#### Required Packages
@@ -274,7 +274,7 @@ fig.layout.template = None
274274
fig.show()
275275
```
276276

277-
Also see Mapbox county choropleths made in Python: [https://plotly.com/python/mapbox-county-choropleth/](https://plotly.com/python/mapbox-county-choropleth/)
277+
Also see tile county choropleths made in Python: [https://plotly.com/python/tile-county-choropleth/](https://plotly.com/python/tile-county-choropleth/)
278278

279279
### Reference
280280

doc/python/datashader.md

+12-16
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.3.0
8+
format_version: '1.3'
9+
jupytext_version: 1.16.3
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.3
23+
version: 3.10.0
2424
plotly:
2525
description: How to use datashader to rasterize large datasets, and visualize
2626
the generated raster data with plotly.
@@ -36,10 +36,10 @@ jupyter:
3636

3737
[datashader](https://datashader.org/) creates rasterized representations of large datasets for easier visualization, with a pipeline approach consisting of several steps: projecting the data on a regular grid, creating a color representation of the grid, etc.
3838

39-
### Passing datashader rasters as a mapbox image layer
39+
### Passing datashader rasters as a tile map image layer
4040

4141
We visualize here the spatial distribution of taxi rides in New York City. A higher density
42-
is observed on major avenues. For more details about mapbox charts, see [the mapbox layers tutorial](/python/mapbox-layers). No mapbox token is needed here.
42+
is observed on major avenues. For more details about tile-based maps, see [the tile map layers tutorial](/python/tile-map-layers).
4343

4444
```python
4545
import pandas as pd
@@ -51,7 +51,7 @@ cvs = ds.Canvas(plot_width=1000, plot_height=1000)
5151
agg = cvs.points(dff, x='Lon', y='Lat')
5252
# agg is an xarray object, see http://xarray.pydata.org/en/stable/ for more details
5353
coords_lat, coords_lon = agg.coords['Lat'].values, agg.coords['Lon'].values
54-
# Corners of the image, which need to be passed to mapbox
54+
# Corners of the image
5555
coordinates = [[coords_lon[0], coords_lat[0]],
5656
[coords_lon[-1], coords_lat[0]],
5757
[coords_lon[-1], coords_lat[-1]],
@@ -62,11 +62,11 @@ import datashader.transfer_functions as tf
6262
img = tf.shade(agg, cmap=fire)[::-1].to_pil()
6363

6464
import plotly.express as px
65-
# Trick to create rapidly a figure with mapbox axes
66-
fig = px.scatter_mapbox(dff[:1], lat='Lat', lon='Lon', zoom=12)
67-
# Add the datashader image as a mapbox layer image
68-
fig.update_layout(mapbox_style="carto-darkmatter",
69-
mapbox_layers = [
65+
# Trick to create rapidly a figure with map axes
66+
fig = px.scatter_map(dff[:1], lat='Lat', lon='Lon', zoom=12)
67+
# Add the datashader image as a tile map layer image
68+
fig.update_layout(map_style="carto-darkmatter",
69+
map_layers = [
7070
{
7171
"sourcetype": "image",
7272
"source": img,
@@ -113,7 +113,3 @@ fig.update_traces(hoverongaps=False)
113113
fig.update_layout(coloraxis_colorbar=dict(title='Count', tickprefix='1.e'))
114114
fig.show()
115115
```
116-
117-
```python
118-
119-
```

doc/python/figure-structure.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ The second of the three top-level attributes of a figure is `layout`, whose valu
9797
* Subplots of various types on which can be drawn multiple traces and which are positioned in paper coordinates:
9898
* `xaxis`, `yaxis`, `xaxis2`, `yaxis3` etc: X and Y cartesian axes, the intersections of which are cartesian subplots
9999
* `scene`, `scene2`, `scene3` etc: 3d scene subplots
100-
* `ternary`, `ternary2`, `ternary3`, `polar`, `polar2`, `polar3`, `geo`, `geo2`, `geo3`, `mapbox`, `mapbox2`, `mabox3`, `smith`, `smith2` etc: ternary, polar, geo, mapbox or smith subplots
100+
* `ternary`, `ternary2`, `ternary3`, `polar`, `polar2`, `polar3`, `geo`, `geo2`, `geo3`, `map`, `map2`, `map3`, `smith`, `smith2` etc: ternary, polar, geo, map or smith subplots
101101
* Non-data marks which can be positioned in paper coordinates, or in data coordinates linked to 2d cartesian subplots:
102102
* `annotations`: [textual annotations with or without arrows](/python/text-and-annotations/)
103103
* `shapes`: [lines, rectangles, ellipses or open or closed paths](/python/shapes/)
@@ -181,18 +181,18 @@ The following trace types are compatible with smith subplots via the `smith` att
181181

182182
### Map Trace Types and Subplots
183183

184-
Figures can include two different types of map subplots: [geo subplots for outline maps](/python/map-configuration/) and [mapbox subplots for tile maps](/python/mapbox-layers/). The following trace types support attributes named `geo` or `mapbox`, whose values must refer to corresponding objects in the layout i.e. `geo="geo2"` etc. Note that attributes such as `layout.geo2` and `layout.mapbox` etc do not have to be explicitly defined, in which case default values will be inferred. Multiple traces of a compatible type can be placed on the same subplot.
184+
Figures can include two different types of map subplots: [geo subplots for outline maps](/python/map-configuration/) and [mapbox subplots for tile maps](/python/tile-map-layers/). The following trace types support attributes named `geo` or `map`, whose values must refer to corresponding objects in the layout i.e. `geo="geo2"` etc. Note that attributes such as `layout.geo2` and `layout.map` etc do not have to be explicitly defined, in which case default values will be inferred. Multiple traces of a compatible type can be placed on the same subplot.
185185

186186
The following trace types are compatible with geo subplots via the `geo` attribute:
187187

188188
* [`scattergeo`](/python/scatter-plots-on-maps/), which can be used to draw [individual markers](/python/scatter-plots-on-maps/), [line and curves](/python/lines-on-maps/) and filled areas on outline maps
189189
* [`choropleth`](/python/choropleth-maps/): [colored polygons](/python/choropleth-maps/) on outline maps
190190

191-
The following trace types are compatible with mapbox subplots via the `mapbox` attribute:
191+
The following trace types are compatible with tile map subplots via the `map` attribute:
192192

193-
* [`scattermapbox`](/python/scattermapbox/), which can be used to draw [individual markers](/python/scattermapbox/), [lines and curves](/python/lines-on-mapbox/) and [filled areas](/python/filled-area-on-mapbox/) on tile maps
194-
* [`choroplethmapbox`](/python/mapbox-county-choropleth/): colored polygons on tile maps
195-
* [`densitymapbox`](/python/mapbox-density-heatmaps/): density heatmaps on tile maps
193+
* [`scattermap`](/python/tile-scatter-maps/), which can be used to draw [individual markers](/python/tile-scatter-maps/), [lines and curves](/python/lines-on-tile-maps/) and [filled areas](/python/filled-area-tile-maps/) on tile maps
194+
* [`choroplethmap`](/python/tile-county-choropleth/): colored polygons on tile maps
195+
* [`densitymap`](/python/tile-density-heatmaps/): density heatmaps on tile maps
196196

197197
### Traces Which Are Their Own Subplots
198198

doc/python/filled-area-on-mapbox.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jupyter:
3636

3737
There are three different ways to show a filled area on a tile-based map:
3838

39-
- Using a [Scattermap](https://plotly.com/python/reference/scattermap/) trace and set `fill` attribute to 'toself'
39+
- Using a [Scattermap](https://plotly.com/python/reference/scattermap/) trace and setting the `fill` attribute to 'toself'
4040
- Using a map layout (i.e. by minimally using an empty [Scattermap](https://plotly.com/python/reference/scattermap/) trace) and adding a GeoJSON layer
4141
- Using the [Choroplethmap](https://plotly.com/python/tile-county-choropleth/) trace type
4242

doc/python/heatmaps.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jupyter:
3434
thumbnail: thumbnail/heatmap.jpg
3535
---
3636

37-
The term "heatmap" usually refers to a cartesian plot with data visualized as colored rectangular tiles, which is the subject of this page. It is also sometimes used to refer to [actual maps with density data displayed as color intensity](/python/mapbox-density-heatmaps/).
37+
The term "heatmap" usually refers to a cartesian plot with data visualized as colored rectangular tiles, which is the subject of this page. It is also sometimes used to refer to [actual maps with density data displayed as color intensity](/python/tile-density-heatmaps/).
3838

3939
Plotly supports two different types of colored-tile heatmaps:
4040

doc/python/hover-text-and-formatting.md

+16-18
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ fig.show()
285285

286286
### Specifying the formatting and labeling of custom fields in a Plotly Express figure using a hovertemplate
287287

288-
This example adds custom fields to a Plotly Express figure using the custom_data parameter and then adds a hover template that applies d3 formats to each element of the customdata[n] array and uses HTML to customize the fonts and spacing.
288+
This example adds custom fields to a Plotly Express figure using the custom_data parameter and then adds a hover template that applies d3 formats to each element of the customdata[n] array and uses HTML to customize the fonts and spacing.
289289

290290
```python
291291
# %%
@@ -301,20 +301,20 @@ df = df.sort_values(['continent', 'country'])
301301

302302
df.rename(columns={"gdpPercap":'GDP per capita', "lifeExp":'Life Expectancy (years)'}, inplace=True)
303303

304-
fig=px.scatter(df,
304+
fig=px.scatter(df,
305305
x='GDP per capita',
306-
y='Life Expectancy (years)',
307-
color='continent',
308-
size=np.sqrt(df['pop']),
306+
y='Life Expectancy (years)',
307+
color='continent',
308+
size=np.sqrt(df['pop']),
309309
# Specifying data to make available to the hovertemplate
310310
# The px custom_data parameter has an underscore, while the analogous graph objects customdata parameter has no underscore.
311311
# The px custom_data parameter is a list of column names in the data frame, while the graph objects customdata parameter expects a data frame or a numpy array.
312-
custom_data=['country', 'continent', 'pop'],
312+
custom_data=['country', 'continent', 'pop'],
313313
)
314314

315315
# Plotly express does not have a hovertemplate parameter in the graph creation function, so we apply the template with update_traces
316316
fig.update_traces(
317-
hovertemplate =
317+
hovertemplate =
318318
"<b>%{customdata[0]}</b><br>" +
319319
"<b>%{customdata[1]}</b><br><br>" +
320320
"GDP per Capita: %{x:$,.0f}<br>" +
@@ -371,7 +371,7 @@ fig.show()
371371

372372
### Advanced Hover Template
373373

374-
This produces the same graphic as in "Specifying the formatting and labeling of custom fields in a Plotly Express figure using a hovertemplate" above, but does so with the `customdata` and `text` parameters of `graph_objects`. It shows how to specify columns from a dataframe to include in the customdata array using the df[["col_i", "col_j"]] subsetting notation. It then references those variables using e.g. %{customdata[0]} in the hovertemplate. It includes comments about major differences between the parameters used by `graph_objects` and `plotly.express`.
374+
This produces the same graphic as in "Specifying the formatting and labeling of custom fields in a Plotly Express figure using a hovertemplate" above, but does so with the `customdata` and `text` parameters of `graph_objects`. It shows how to specify columns from a dataframe to include in the customdata array using the df[["col_i", "col_j"]] subsetting notation. It then references those variables using e.g. %{customdata[0]} in the hovertemplate. It includes comments about major differences between the parameters used by `graph_objects` and `plotly.express`.
375375

376376
```python
377377
import plotly.graph_objects as go
@@ -404,12 +404,12 @@ for continent_name, df in continent_data.items():
404404
name=continent_name,
405405

406406
# The next three parameters specify the hover text
407-
# Text supports just one customized field per trace
408-
# and is implemented here with text=df['continent'],
409-
# Custom data supports multiple fields through numeric indices in the hovertemplate
410-
# In we weren't using the text parameter in our example,
407+
# Text supports just one customized field per trace
408+
# and is implemented here with text=df['continent'],
409+
# Custom data supports multiple fields through numeric indices in the hovertemplate
410+
# In we weren't using the text parameter in our example,
411411
# we could instead add continent as a third customdata field.
412-
customdata=df[['country','pop']],
412+
customdata=df[['country','pop']],
413413
hovertemplate=
414414
"<b>%{customdata[0]}</b><br>" +
415415
"<b>%{text}</b><br><br>" +
@@ -462,14 +462,12 @@ fig.update_layout(title_text='Hover to see the value of z1, z2 and z3 together')
462462
fig.show()
463463
```
464464

465-
### Setting the Hover Template in Mapbox Maps
465+
### Setting the Hover Template in Tile Maps
466466

467467
```python
468468
import plotly.graph_objects as go
469469

470-
token = open(".mapbox_token").read() # you need your own token
471-
472-
fig = go.Figure(go.Scattermapbox(
470+
fig = go.Figure(go.Scattermap(
473471
name = "",
474472
mode = "markers+text+lines",
475473
lon = [-75, -80, -50],
@@ -481,7 +479,7 @@ fig = go.Figure(go.Scattermapbox(
481479
"latitude: %{lat}<br>" ))
482480

483481
fig.update_layout(
484-
mapbox = {
482+
map = {
485483
'accesstoken': token,
486484
'style': "outdoors", 'zoom': 1},
487485
showlegend = False)

0 commit comments

Comments
 (0)