diff --git a/packages/python/plotly/codegen/datatypes.py b/packages/python/plotly/codegen/datatypes.py index b9ff134fb4..deb1c9bbdf 100644 --- a/packages/python/plotly/codegen/datatypes.py +++ b/packages/python/plotly/codegen/datatypes.py @@ -5,6 +5,13 @@ from codegen.utils import PlotlyNode, write_source_py +deprecated_mapbox_traces = [ + "scattermapbox", + "choroplethmapbox", + "densitymapbox", +] + + def get_typing_type(plotly_type, array_ok=False): """ Get Python type corresponding to a valType string from the plotly schema @@ -95,6 +102,9 @@ def build_datatype_py(node): ) buffer.write(f"import copy as _copy\n") + if node.name_property in deprecated_mapbox_traces: + buffer.write(f"from warnings import warn\n") + # Write class definition # ---------------------- buffer.write( @@ -400,6 +410,19 @@ def __init__(self""" """ ) + if node.name_property in deprecated_mapbox_traces: + buffer.write( + f""" + 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() diff --git a/packages/python/plotly/plotly/express/_chart_types.py b/packages/python/plotly/plotly/express/_chart_types.py index 614431f19a..9ec2b4a6a6 100644 --- a/packages/python/plotly/plotly/express/_chart_types.py +++ b/packages/python/plotly/plotly/express/_chart_types.py @@ -1,3 +1,5 @@ +from warnings import warn + from ._core import make_figure from ._doc import make_docstring import plotly.graph_objs as go @@ -1415,9 +1417,18 @@ def scatter_mapbox( height=None, ) -> go.Figure: """ + *scatter_mapbox* is deprecated! Use *scatter_map* instead. + Learn more at: https://plotly.com/python/mapbox-to-maplibre/ In a Mapbox scatter plot, each row of `data_frame` is represented by a symbol mark on a Mapbox map. """ + warn( + "*scatter_mapbox* is deprecated!" + + " Use *scatter_map* instead." + + " Learn more at: https://plotly.com/python/mapbox-to-maplibre/", + stacklevel=2, + category=DeprecationWarning, + ) return make_figure(args=locals(), constructor=go.Scattermapbox) @@ -1453,9 +1464,18 @@ def choropleth_mapbox( height=None, ) -> go.Figure: """ + *choropleth_mapbox* is deprecated! Use *choropleth_map* instead. + Learn more at: https://plotly.com/python/mapbox-to-maplibre/ In a Mapbox choropleth map, each row of `data_frame` is represented by a colored region on a Mapbox map. """ + warn( + "*choropleth_mapbox* is deprecated!" + + " Use *choropleth_map* instead." + + " Learn more at: https://plotly.com/python/mapbox-to-maplibre/", + stacklevel=2, + category=DeprecationWarning, + ) return make_figure(args=locals(), constructor=go.Choroplethmapbox) @@ -1489,9 +1509,18 @@ def density_mapbox( height=None, ) -> go.Figure: """ + *density_mapbox* is deprecated! Use *density_map* instead. + Learn more at: https://plotly.com/python/mapbox-to-maplibre/ In a Mapbox density map, each row of `data_frame` contributes to the intensity of the color of the region around the corresponding point on the map """ + warn( + "*density_mapbox* is deprecated!" + + " Use *density_map* instead." + + " Learn more at: https://plotly.com/python/mapbox-to-maplibre/", + stacklevel=2, + category=DeprecationWarning, + ) return make_figure( args=locals(), constructor=go.Densitymapbox, trace_patch=dict(radius=radius) ) @@ -1526,9 +1555,18 @@ def line_mapbox( height=None, ) -> go.Figure: """ + *line_mapbox* is deprecated! Use *line_map* instead. + Learn more at: https://plotly.com/python/mapbox-to-maplibre/ In a Mapbox line plot, each row of `data_frame` is represented as a vertex of a polyline mark on a Mapbox map. """ + warn( + "*line_mapbox* is deprecated!" + + " Use *line_map* instead." + + " Learn more at: https://plotly.com/python/mapbox-to-maplibre/", + stacklevel=2, + category=DeprecationWarning, + ) return make_figure(args=locals(), constructor=go.Scattermapbox) diff --git a/packages/python/plotly/plotly/graph_objs/_choroplethmapbox.py b/packages/python/plotly/plotly/graph_objs/_choroplethmapbox.py index f07047a991..c1c14e6d4a 100644 --- a/packages/python/plotly/plotly/graph_objs/_choroplethmapbox.py +++ b/packages/python/plotly/plotly/graph_objs/_choroplethmapbox.py @@ -1,5 +1,6 @@ from plotly.basedatatypes import BaseTraceType as _BaseTraceType import copy as _copy +from warnings import warn class Choroplethmapbox(_BaseTraceType): @@ -2378,3 +2379,11 @@ def __init__( # Reset skip_invalid # ------------------ self._skip_invalid = False + + warn( + "*choroplethmapbox* is deprecated!" + + " Use *choroplethmap* instead." + + " Learn more at: https://plotly.com/python/mapbox-to-maplibre/", + stacklevel=2, + category=DeprecationWarning, + ) diff --git a/packages/python/plotly/plotly/graph_objs/_densitymapbox.py b/packages/python/plotly/plotly/graph_objs/_densitymapbox.py index 7d2c41e126..8498ab2d17 100644 --- a/packages/python/plotly/plotly/graph_objs/_densitymapbox.py +++ b/packages/python/plotly/plotly/graph_objs/_densitymapbox.py @@ -1,5 +1,6 @@ from plotly.basedatatypes import BaseTraceType as _BaseTraceType import copy as _copy +from warnings import warn class Densitymapbox(_BaseTraceType): @@ -2319,3 +2320,11 @@ def __init__( # Reset skip_invalid # ------------------ self._skip_invalid = False + + warn( + "*densitymapbox* is deprecated!" + + " Use *densitymap* instead." + + " Learn more at: https://plotly.com/python/mapbox-to-maplibre/", + stacklevel=2, + category=DeprecationWarning, + ) diff --git a/packages/python/plotly/plotly/graph_objs/_scattermapbox.py b/packages/python/plotly/plotly/graph_objs/_scattermapbox.py index 34e72ecf03..c7494d48fb 100644 --- a/packages/python/plotly/plotly/graph_objs/_scattermapbox.py +++ b/packages/python/plotly/plotly/graph_objs/_scattermapbox.py @@ -1,5 +1,6 @@ from plotly.basedatatypes import BaseTraceType as _BaseTraceType import copy as _copy +from warnings import warn class Scattermapbox(_BaseTraceType): @@ -2292,3 +2293,11 @@ def __init__( # Reset skip_invalid # ------------------ self._skip_invalid = False + + warn( + "*scattermapbox* is deprecated!" + + " Use *scattermap* instead." + + " Learn more at: https://plotly.com/python/mapbox-to-maplibre/", + stacklevel=2, + category=DeprecationWarning, + )