Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4a21e76

Browse files
authored
Merge pull request #4900 from plotly/v6-mapbox-deprecated-warning
Fix: Display deprecated warnings for mapbox traces
2 parents 0a4f0a0 + 5d113b9 commit 4a21e76

File tree

5 files changed

+88
-0
lines changed

5 files changed

+88
-0
lines changed

‎packages/python/plotly/codegen/datatypes.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
from codegen.utils import PlotlyNode, write_source_py
66

77

8+
deprecated_mapbox_traces = [
9+
"scattermapbox",
10+
"choroplethmapbox",
11+
"densitymapbox",
12+
]
13+
14+
815
def get_typing_type(plotly_type, array_ok=False):
916
"""
1017
Get Python type corresponding to a valType string from the plotly schema
@@ -95,6 +102,9 @@ def build_datatype_py(node):
95102
)
96103
buffer.write(f"import copy as _copy\n")
97104

105+
if node.name_property in deprecated_mapbox_traces:
106+
buffer.write(f"from warnings import warn\n")
107+
98108
# Write class definition
99109
# ----------------------
100110
buffer.write(
@@ -400,6 +410,19 @@ def __init__(self"""
400410
"""
401411
)
402412

413+
if node.name_property in deprecated_mapbox_traces:
414+
buffer.write(
415+
f"""
416+
warn(
417+
"*{node.name_property}* is deprecated!"
418+
+ " Use *{node.name_property.replace("mapbox", "map")}* instead."
419+
+ " Learn more at: https://plotly.com/python/mapbox-to-maplibre/",
420+
stacklevel=2,
421+
category=DeprecationWarning,
422+
)
423+
"""
424+
)
425+
403426
# Return source string
404427
# --------------------
405428
return buffer.getvalue()

‎packages/python/plotly/plotly/express/_chart_types.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from warnings import warn
2+
13
from ._core import make_figure
24
from ._doc import make_docstring
35
import plotly.graph_objs as go
@@ -1415,9 +1417,18 @@ def scatter_mapbox(
14151417
height=None,
14161418
) -> go.Figure:
14171419
"""
1420+
*scatter_mapbox* is deprecated! Use *scatter_map* instead.
1421+
Learn more at: https://plotly.com/python/mapbox-to-maplibre/
14181422
In a Mapbox scatter plot, each row of `data_frame` is represented by a
14191423
symbol mark on a Mapbox map.
14201424
"""
1425+
warn(
1426+
"*scatter_mapbox* is deprecated!"
1427+
+ " Use *scatter_map* instead."
1428+
+ " Learn more at: https://plotly.com/python/mapbox-to-maplibre/",
1429+
stacklevel=2,
1430+
category=DeprecationWarning,
1431+
)
14211432
return make_figure(args=locals(), constructor=go.Scattermapbox)
14221433

14231434

@@ -1453,9 +1464,18 @@ def choropleth_mapbox(
14531464
height=None,
14541465
) -> go.Figure:
14551466
"""
1467+
*choropleth_mapbox* is deprecated! Use *choropleth_map* instead.
1468+
Learn more at: https://plotly.com/python/mapbox-to-maplibre/
14561469
In a Mapbox choropleth map, each row of `data_frame` is represented by a
14571470
colored region on a Mapbox map.
14581471
"""
1472+
warn(
1473+
"*choropleth_mapbox* is deprecated!"
1474+
+ " Use *choropleth_map* instead."
1475+
+ " Learn more at: https://plotly.com/python/mapbox-to-maplibre/",
1476+
stacklevel=2,
1477+
category=DeprecationWarning,
1478+
)
14591479
return make_figure(args=locals(), constructor=go.Choroplethmapbox)
14601480

14611481

@@ -1489,9 +1509,18 @@ def density_mapbox(
14891509
height=None,
14901510
) -> go.Figure:
14911511
"""
1512+
*density_mapbox* is deprecated! Use *density_map* instead.
1513+
Learn more at: https://plotly.com/python/mapbox-to-maplibre/
14921514
In a Mapbox density map, each row of `data_frame` contributes to the intensity of
14931515
the color of the region around the corresponding point on the map
14941516
"""
1517+
warn(
1518+
"*density_mapbox* is deprecated!"
1519+
+ " Use *density_map* instead."
1520+
+ " Learn more at: https://plotly.com/python/mapbox-to-maplibre/",
1521+
stacklevel=2,
1522+
category=DeprecationWarning,
1523+
)
14951524
return make_figure(
14961525
args=locals(), constructor=go.Densitymapbox, trace_patch=dict(radius=radius)
14971526
)
@@ -1526,9 +1555,18 @@ def line_mapbox(
15261555
height=None,
15271556
) -> go.Figure:
15281557
"""
1558+
*line_mapbox* is deprecated! Use *line_map* instead.
1559+
Learn more at: https://plotly.com/python/mapbox-to-maplibre/
15291560
In a Mapbox line plot, each row of `data_frame` is represented as
15301561
a vertex of a polyline mark on a Mapbox map.
15311562
"""
1563+
warn(
1564+
"*line_mapbox* is deprecated!"
1565+
+ " Use *line_map* instead."
1566+
+ " Learn more at: https://plotly.com/python/mapbox-to-maplibre/",
1567+
stacklevel=2,
1568+
category=DeprecationWarning,
1569+
)
15321570
return make_figure(args=locals(), constructor=go.Scattermapbox)
15331571

15341572

‎packages/python/plotly/plotly/graph_objs/_choroplethmapbox.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from plotly.basedatatypes import BaseTraceType as _BaseTraceType
22
import copy as _copy
3+
from warnings import warn
34

45

56
class Choroplethmapbox(_BaseTraceType):
@@ -2378,3 +2379,11 @@ def __init__(
23782379
# Reset skip_invalid
23792380
# ------------------
23802381
self._skip_invalid = False
2382+
2383+
warn(
2384+
"*choroplethmapbox* is deprecated!"
2385+
+ " Use *choroplethmap* instead."
2386+
+ " Learn more at: https://plotly.com/python/mapbox-to-maplibre/",
2387+
stacklevel=2,
2388+
category=DeprecationWarning,
2389+
)

‎packages/python/plotly/plotly/graph_objs/_densitymapbox.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from plotly.basedatatypes import BaseTraceType as _BaseTraceType
22
import copy as _copy
3+
from warnings import warn
34

45

56
class Densitymapbox(_BaseTraceType):
@@ -2319,3 +2320,11 @@ def __init__(
23192320
# Reset skip_invalid
23202321
# ------------------
23212322
self._skip_invalid = False
2323+
2324+
warn(
2325+
"*densitymapbox* is deprecated!"
2326+
+ " Use *densitymap* instead."
2327+
+ " Learn more at: https://plotly.com/python/mapbox-to-maplibre/",
2328+
stacklevel=2,
2329+
category=DeprecationWarning,
2330+
)

‎packages/python/plotly/plotly/graph_objs/_scattermapbox.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from plotly.basedatatypes import BaseTraceType as _BaseTraceType
22
import copy as _copy
3+
from warnings import warn
34

45

56
class Scattermapbox(_BaseTraceType):
@@ -2292,3 +2293,11 @@ def __init__(
22922293
# Reset skip_invalid
22932294
# ------------------
22942295
self._skip_invalid = False
2296+
2297+
warn(
2298+
"*scattermapbox* is deprecated!"
2299+
+ " Use *scattermap* instead."
2300+
+ " Learn more at: https://plotly.com/python/mapbox-to-maplibre/",
2301+
stacklevel=2,
2302+
category=DeprecationWarning,
2303+
)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /