From d634d59bf2612aed01342e30a9d2d289d87e4567 Mon Sep 17 00:00:00 2001 From: Emily KL <4672118+emilykl@users.noreply.github.com> Date: Wed, 29 Jul 2026 17:54:56 -0400 Subject: [PATCH 1/4] Remove auto-center behavior and hard-coded default zoom from px *_map() functions (now handled in plotly.js). Note: choropleth map auto-centering is not yet supported in plotly.js, but the default plotly.js zoom of 1 is still better than an arbitrary zoom of 8. --- plotly/express/_chart_types.py | 8 ++++---- plotly/express/_core.py | 8 +------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/plotly/express/_chart_types.py b/plotly/express/_chart_types.py index fd353d1a00..ad5f01d8b9 100644 --- a/plotly/express/_chart_types.py +++ b/plotly/express/_chart_types.py @@ -1258,7 +1258,7 @@ def scatter_map( color_continuous_midpoint=None, opacity=None, size_max=None, - zoom=8, + zoom=None, center=None, map_style=None, title=None, @@ -1296,7 +1296,7 @@ def choropleth_map( range_color=None, color_continuous_midpoint=None, opacity=None, - zoom=8, + zoom=None, center=None, map_style=None, title=None, @@ -1331,7 +1331,7 @@ def density_map( range_color=None, color_continuous_midpoint=None, opacity=None, - zoom=8, + zoom=None, center=None, map_style=None, radius=None, @@ -1369,7 +1369,7 @@ def line_map( labels=None, color_discrete_sequence=None, color_discrete_map=None, - zoom=8, + zoom=None, center=None, map_style=None, title=None, diff --git a/plotly/express/_core.py b/plotly/express/_core.py index ddc98e67aa..9516402d84 100644 --- a/plotly/express/_core.py +++ b/plotly/express/_core.py @@ -793,14 +793,8 @@ def configure_3d_axes(args, fig, orders): def configure_map(args, fig, orders): - center = args["center"] - if not center and "lat" in args and "lon" in args: - center = dict( - lat=args["data_frame"][args["lat"]].mean(), - lon=args["data_frame"][args["lon"]].mean(), - ) fig.update_maps( - center=center, + center=args["center"], zoom=args["zoom"], style=args["map_style"], ) From 9ac02ce37cfc71c1b1d6ba47d11d62505590068d Mon Sep 17 00:00:00 2001 From: Emily KL <4672118+emilykl@users.noreply.github.com> Date: Wed, 29 Jul 2026 18:54:03 -0400 Subject: [PATCH 2/4] remove hard-coded zoom from px.scatter_map() Percy test, to visually test auto-fit behavior --- tests/percy/plotly-express.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/percy/plotly-express.py b/tests/percy/plotly-express.py index 9592b0b35d..a7bd980c32 100644 --- a/tests/percy/plotly-express.py +++ b/tests/percy/plotly-express.py @@ -386,7 +386,6 @@ size="car_hours", color_continuous_scale=px.colors.cyclical.IceFire, size_max=15, - zoom=10, ) fig.write_html(os.path.join(dir_name, "scatter_map.html")) From 0e495c0fb269a8be38a6f6d9bc482684b10ad7bb Mon Sep 17 00:00:00 2001 From: Emily KL <4672118+emilykl@users.noreply.github.com> Date: Wed, 29 Jul 2026 19:39:20 -0400 Subject: [PATCH 3/4] update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 898bc1bf4c..32b89c0479 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## Unreleased +### Fixed +- Improve `px.*_map()` auto-fitting behavior when `zoom` and `center` are not specified [[#5686](https://github.com/plotly/plotly.py/pull/5686)] + ## [7.0.0rc0] - 2026-07-29 From 79d791ac982d334c3f75e0fb972a3f1e3783b173 Mon Sep 17 00:00:00 2001 From: Emily KL <4672118+emilykl@users.noreply.github.com> Date: Thu, 30 Jul 2026 12:01:38 -0400 Subject: [PATCH 4/4] update zoom docstring --- plotly/express/_doc.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plotly/express/_doc.py b/plotly/express/_doc.py index 3df6a19159..42cb991df1 100644 --- a/plotly/express/_doc.py +++ b/plotly/express/_doc.py @@ -500,7 +500,12 @@ "In `'overlay'` mode, strips are on drawn top of one another.", "In `'group'` mode, strips are placed beside each other.", ], - zoom=["int (default `8`)", "Between 0 and 20.", "Sets map zoom level."], + zoom=[ + "int (default `None`)", + "Between 0 and 20.", + "Sets initial map zoom level. Higher values are more zoomed-in.", + "If not provided, the map will select its own zoom level.", + ], orientation=[ "str, one of `'h'` for horizontal or `'v'` for vertical. ", "(default `'v'` if `x` and `y` are provided and both continuous or both categorical, ",