Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 0 additions & 3 deletions .github/workflows/build-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,9 @@ jobs:


- name: Build HTML docs
env:
MAPBOX_TOKEN: ${{ secrets.MAPBOX_TOKEN }}
run: |
cd doc
source .venv/bin/activate
echo "${MAPBOX_TOKEN}" > python/.mapbox_token
make -kj8 || make -kj8
curl https://raw.githubusercontent.com/plotly/graphing-library-docs/master/front-matter-ci.py > front-matter-ci.py
curl https://raw.githubusercontent.com/plotly/graphing-library-docs/master/check-or-enforce-order.py > check-or-enforce-order.py
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ tests/test_core/test_offline/plotly.min.js
temp-plot.html
.vscode
doc/python/.ipynb_checkpoints
doc/python/.mapbox_token
doc/.ipynb_checkpoints
tags
doc/check-or-enforce-order.py
Expand Down
42 changes: 4 additions & 38 deletions codegen/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
from codegen.utils import CAVEAT, write_source_py


deprecated_mapbox_traces = [
"scattermapbox",
"choroplethmapbox",
"densitymapbox",
]
locationmode_traces = [
"choropleth",
"scattergeo",
Expand Down Expand Up @@ -102,11 +97,7 @@ def build_datatype_py(node):
)
buffer.write("import copy as _copy\n")

if (
node.name_property in deprecated_mapbox_traces
or node.name_property in locationmode_traces
or node.name_property == "template"
):
if node.name_property in locationmode_traces or node.name_property == "template":
buffer.write("import warnings\n")

# Write class definition
Expand Down Expand Up @@ -375,22 +366,10 @@ def __init__(self"""
buffer.write("\n\n")
for subtype_node in subtype_nodes:
name_prop = subtype_node.name_property
if datatype_class == "Template" and name_prop == "data":
buffer.write(
f"""
# Template.data contains a 'scattermapbox' key, which causes a
# go.Scattermapbox trace object to be created during validation.
# In order to prevent false deprecation warnings from surfacing,
# we suppress deprecation warnings for this line only.
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
self._set_property("{name_prop}", arg, {name_prop})"""
)
else:
buffer.write(
f"""
buffer.write(
f"""
self._set_property("{name_prop}", arg, {name_prop})"""
)
)

# Literals
if literal_nodes:
Expand All @@ -411,19 +390,6 @@ def __init__(self"""
"""
)

if node.name_property in deprecated_mapbox_traces:
buffer.write(
f"""
warnings.warn(
"*{node.name_property}* is deprecated!"
+ " Use *{node.name_property.replace("mapbox", "map")}* instead."
+ " Learn more at: https://plotly.com/python/mapbox-to-maplibre/",
stacklevel=2,
category=DeprecationWarning,
)
"""
)

# Return source string
return buffer.getvalue()

Expand Down
49,612 changes: 18,432 additions & 31,180 deletions codegen/resources/plot-schema.json

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ all: $(HTML_FILES) $(V3_REDIR_FILES) $(NEXT_REDIR_FILES)

.PRECIOUS: $(IPYNB_FILES)

$(IPYNB_DIR)/.mapbox_token: $(MD_DIR)/.mapbox_token
@mkdir -p $(IPYNB_DIR)
@echo "[symlink] .mapbox_token"
@cd $(IPYNB_DIR) && ln -s ../../$<

$(IPYNB_FILES): $(IPYNB_DIR)/.mapbox_token

$(IPYNB_DIR)/%.ipynb: $(MD_DIR)/%.md
@mkdir -p $(IPYNB_DIR)
@echo "[jupytext] $<"
Expand Down
13 changes: 0 additions & 13 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,6 @@ uv pip uninstall plotly # remove the PyPI version installed by requirement
uv pip install -e .. # install from your local checkout
```

### Mapbox token

Several geographic examples require a free Mapbox public token. Without it,
those specific pages will fail to build.

1. Create an account at https://account.mapbox.com/auth/signup
2. Navigate to https://account.mapbox.com/ and copy your "Default public token"
3. Save it to the file `doc/python/.mapbox_token`

The Makefile symlinks this token into the build directory automatically.

## Tutorials (`python` directory)

Each tutorial is a markdown (`.md`) file, which can be opened in Jupyter
Expand Down Expand Up @@ -391,8 +380,6 @@ Check `build/failures/<page-name>` for the full error output. Common causes:
- **Timeout** — the default is 600 seconds (10 minutes). If your example
legitimately needs more time, discuss in an issue before increasing the
timeout.
- **Missing Mapbox token** — geographic examples will fail if
`doc/python/.mapbox_token` does not exist.

### `make` fails immediately

Expand Down
5 changes: 0 additions & 5 deletions doc/apidoc/plotly.express.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ plotly's high-level API for rapid figure generation. ::
scatter_polar
scatter_ternary
scatter_map
scatter_mapbox
scatter_geo
line
line_3d
line_polar
line_ternary
line_map
line_mapbox
line_geo
area
bar
Expand All @@ -48,13 +46,10 @@ plotly's high-level API for rapid figure generation. ::
parallel_categories
choropleth
choropleth_map
choropleth_mapbox
density_contour
density_heatmap
density_map
density_mapbox
imshow
set_mapbox_access_token
get_trendline_results


Expand Down
3 changes: 0 additions & 3 deletions doc/apidoc/plotly.graph_objects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ Map Traces
Scattermap
Choroplethmap
Densitymap
Scattermapbox
Choroplethmapbox
Densitymapbox

Specialized Traces
-----------
Expand Down
4 changes: 2 additions & 2 deletions doc/python/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ To delete buttons from the modebar, pass an array of strings containing the name
- **3D**: `zoom3d`, `pan3d`, `orbitRotation`, `tableRotation`, `handleDrag3d`, `resetCameraDefault3d`, `resetCameraLastSave3d`, `hoverClosest3d`
- **Cartesian**: `hoverClosestCartesian`, `hoverCompareCartesian`
- **Geo**: `zoomInGeo`, `zoomOutGeo`, `resetGeo`, `hoverClosestGeo`
- **Other**: `hoverClosestGl2d`, `hoverClosestPie`, `toggleHover`, `resetViews`, `toImage`, `sendDataToCloud`, `toggleSpikelines`, `resetViewMapbox`
- **Other**: `hoverClosestGl2d`, `hoverClosestPie`, `toggleHover`, `resetViews`, `toImage`, `sendDataToCloud`, `toggleSpikelines`, `resetViewMap`

```python
import plotly.graph_objects as go
Expand Down Expand Up @@ -305,7 +305,7 @@ fig.show()

### Double-Click Delay
Sets the maximum delay between two consecutive clicks to be interpreted as a double-click in milliseconds. This is the time interval between first mousedown and second mouseup. The default timing is 300 ms (less than half a second).
This setting propagates to all on-subplot double clicks (except for `geo` and `mapbox`).
This setting propagates to all on-subplot double clicks (except for `geo` and `map`).

```python
import plotly.graph_objects as go
Expand Down
51 changes: 2 additions & 49 deletions doc/python/density-heatmaps.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jupyter:
page_type: u-guide
permalink: python/density-heatmaps/
redirect_from: python/mapbox-density-heatmaps/
thumbnail: thumbnail/mapbox-density.png
thumbnail: thumbnail/map-density.png
---

### Density map with `plotly.express`
Expand Down Expand Up @@ -67,55 +67,8 @@ fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
```

<!-- #region -->
### Mapbox Maps

> Mapbox traces are deprecated and may be removed in a future version of Plotly.py.

The earlier examples using `px.density_map` and `go.Densitymap` use [Maplibre](https://maplibre.org/maplibre-gl-js/docs/) for rendering. These traces were introduced in Plotly.py 5.24. These trace types are now the recommended way to make tile-based density heatmaps. There are also traces that use [Mapbox](https://docs.mapbox.com): `density_mapbox` and `go.Densitymapbox`.

To use these trace types, in some cases you _may_ need a Mapbox account and a public [Mapbox Access Token](https://www.mapbox.com/studio). See our [Mapbox Map Layers](/python/mapbox-layers/) documentation for more information.

Here's one of the earlier examples rewritten to use `px.density_mapbox`.

```python
import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/earthquakes-23k.csv')

import plotly.express as px
fig = px.density_mapbox(df, lat='Latitude', lon='Longitude', z='Magnitude', radius=10,
center=dict(lat=0, lon=180), zoom=0,
mapbox_style="open-street-map")
fig.show()
```

<!-- #endregion -->

<!-- #region -->
#### Stamen Terrain base map with Mapbox (Stadia Maps token needed): density heatmap with `plotly.express`

Some base maps require a token. To use "stamen" base maps, you'll need a [Stadia Maps](https://www.stadiamaps.com) token, which you can provide to the `mapbox_accesstoken` parameter on `fig.update_layout`. Here, we have the token saved in a file called `.mapbox_token`, load it in to the variable `token`, and then pass it to `mapbox_accesstoken`.

```python
import plotly.express as px
import pandas as pd

token = open(".mapbox_token").read() # you will need your own token

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/earthquakes-23k.csv')

fig = px.density_mapbox(df, lat='Latitude', lon='Longitude', z='Magnitude', radius=10,
center=dict(lat=0, lon=180), zoom=0,
map_style="stamen-terrain")
fig.update_layout(mapbox_accesstoken=token)
fig.show()
```


<!-- #endregion -->

#### Reference

See [function reference for `px.(density_map)`](https://plotly.com/python-api-reference/generated/plotly.express.density_mapbox) or https://plotly.com/python/reference/densitymap/ for available attribute options.
See [function reference for `px.(density_map)`](https://plotly.com/python-api-reference/generated/plotly.express.density_map) or https://plotly.com/python/reference/densitymap/ for available attribute options.

For Mapbox-based maps, see [function reference for `px.(density_mapbox)`](https://plotly.com/python-api-reference/generated/plotly.express.density_mapbox) or https://plotly.com/python/reference/densitymapbox/.
4 changes: 2 additions & 2 deletions doc/python/figure-factories.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ The `plotly.figure_factory` module contains dedicated functions for creating ver
The following plot types can be created with Figure Factory:

* [Dendrograms](/python/dendrogram/)
* [Hexagonal Binning Tile Map](/python/hexbin-mapbox/)
* [Hexagonal Binning Tile Map](/python/hexbin-map/)
* [Quiver Plots](/python/quiver-plots/)
* [Streamline Plots](/python/streamline-plots/)
* [Tables](/python/figure-factory-table/)
Expand All @@ -57,7 +57,7 @@ The following legacy Figure Factory functions have been replaced by Plotly Expre
* `create_distplot`: use [Plotly Express](/python/plotly-express/) functions like [`px.histogram`](/python/histograms/)
* `create_facet_grid`: use [Plotly Express](/python/plotly-express/) functions with the [`facet_row` and `facet_col` arguments](/python/facet-plots/)
* `create_gantt`: use [`px.timeline`](/python/gantt/)
* `create_hexbin_mapbox`: use [`create_hexbin_map`](/python/hexbin-mapbox/)
* `create_hexbin_mapbox`: use [`create_hexbin_map`](/python/hexbin-map/)
* `create_ohlc`: use [`go.Ohlc`](/python/ohlc-charts/)
* `create_scatterplotmatrix`: use [`go.Splom`](/python/splom/)
* `create_violin`: use [`go.Violin`](/python/violin/)
Expand Down
31 changes: 1 addition & 30 deletions doc/python/filled-area-tile-maps.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,36 +134,7 @@ fig.update_layout(
fig.show()
```

<!-- #region -->
### Mapbox Maps

> Mapbox traces are deprecated and may be removed in a future version of Plotly.py.

The earlier examples using `go.Scattermap` use [Maplibre](https://maplibre.org/maplibre-gl-js/docs/) for rendering. This trace was introduced in Plotly.py 5.24 and is now the recommended way to draw filled areas on tile-based maps. There is also a trace that uses [Mapbox](https://docs.mapbox.com), called `go.Scattermapbox`.

To use the `Scattermapbox` trace type, in some cases you _may_ need a Mapbox account and a public [Mapbox Access Token](https://www.mapbox.com/studio). See our [Mapbox Map Layers](/python/mapbox-layers/) documentation for more information.

Here's one of the earlier examples rewritten to use `Scattermapbox`.

```python
import plotly.graph_objects as go

fig = go.Figure(go.Scattermapbox(
fill = "toself",
lon = [-74, -70, -70, -74], lat = [47, 47, 45, 45],
marker = { 'size': 10, 'color': "orange" }))

fig.update_layout(
mapbox = {
'style': "open-street-map",
'center': {'lon': -73, 'lat': 46 },
'zoom': 5},
showlegend = False)

fig.show()
```
<!-- #endregion -->

#### Reference

See https://plotly.com/python/reference/scattermap/ for available attribute options, or for `go.Scattermapbox`, see https://plotly.com/python/reference/scattermapbox/.
See https://plotly.com/python/reference/scattermap/ for available attribute options.
6 changes: 3 additions & 3 deletions doc/python/hexbin-mapbox.md → doc/python/hexbin-map.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ jupyter:
display_as: maps
language: python
layout: base
name: Hexbin Mapbox
name: Hexbin Map
order: 13
page_type: u-guide
permalink: python/hexbin-mapbox/
thumbnail: thumbnail/hexbin_mapbox.jpg
permalink: python/hexbin-map/
thumbnail: thumbnail/hexbin_map.jpg
---

#### Simple Count Hexbin
Expand Down
44 changes: 2 additions & 42 deletions doc/python/lines-on-tile-maps.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jupyter:
page_type: example_index
permalink: python/lines-on-tile-maps/
redirect_from: python/lines-on-mapbox/
thumbnail: thumbnail/line_mapbox.jpg
thumbnail: thumbnail/line_map.jpg
---

### Lines on tile maps using Plotly Express
Expand Down Expand Up @@ -99,7 +99,7 @@ fig.show()
### Lines on maps using `Scattermap` traces

This example uses `go.Scattermap` and sets
the [mode](https://plotly.com/python/reference/scattermapbox/#scattermap-mode) attribute to a combination of markers and line.
the [mode](https://plotly.com/python/reference/scattermap/#scattermap-mode) attribute to a combination of markers and line.

```python
import plotly.graph_objects as go
Expand Down Expand Up @@ -127,48 +127,8 @@ fig.update_layout(
fig.show()
```

### Mapbox Maps

> Mapbox traces are deprecated and may be removed in a future version of Plotly.py.

The earlier examples using `px.line_map` and `go.Scattermap` use [Maplibre](https://maplibre.org/maplibre-gl-js/docs/) for rendering. These traces were introduced in Plotly.py 5.24 and are now the recommended way to draw lines on tile-based maps. There are also traces that use [Mapbox](https://docs.mapbox.com): `px.line_mapbox` and `go.Scattermapbox`

To plot on Mapbox maps with Plotly you _may_ need a Mapbox account and a public [Mapbox Access Token](https://www.mapbox.com/studio). See our [Mapbox Map Layers](/python/mapbox-layers/) documentation for more information.

To draw a line on your map, you either can use [`px.line_mapbox`](https://plotly.com/python-api-reference/generated/plotly.express.line_mapbox.html) in Plotly Express, or [`Scattermapbox`](https://plotly.com/python/reference/scattermapbox/) traces. Below we show you how to draw a line on Mapbox using Plotly Express.

Here's an example of using `Scattermapbox`.

```python
import plotly.graph_objects as go

fig = go.Figure(go.Scattermapbox(
mode = "markers+lines",
lon = [10, 20, 30],
lat = [10, 20,30],
marker = {'size': 10}))

fig.add_trace(go.Scattermapbox(
mode = "markers+lines",
lon = [-50, -60,40],
lat = [30, 10, -20],
marker = {'size': 10}))

fig.update_layout(
margin ={'l':0,'t':0,'b':0,'r':0},
mapbox = {
'center': {'lon': 10, 'lat': 10},
'style': "open-street-map",
'center': {'lon': -20, 'lat': -20},
'zoom': 1})

fig.show()
```

#### Reference

See [function reference for `px.line_map`](https://plotly.com/python-api-reference/generated/plotly.express.line_map) or
https://plotly.com/python/reference/scattermap/ for more information about the attributes available.

For Mapbox-based tile maps, see [function reference for `px.line_mapbox`](https://plotly.com/python-api-reference/generated/plotly.express.line_mapbox) or
https://plotly.com/python/reference/scattermapbox/.
Loading
Loading