diff --git a/plotly/_subplots.py b/plotly/_subplots.py index a1bb4219c94..638e08543c0 100644 --- a/plotly/_subplots.py +++ b/plotly/_subplots.py @@ -33,10 +33,8 @@ def _get_initial_max_subplot_ids(): - max_subplot_ids = {subplot_type: 0 for subplot_type in _single_subplot_types} - max_subplot_ids["xaxis"] = 0 - max_subplot_ids["yaxis"] = 0 - return max_subplot_ids + # Return a copy to ensure caller can't mutate the shared dict + return _INITIAL_MAX_SUBPLOT_IDS.copy() def make_subplots( @@ -1535,3 +1533,5 @@ def _get_subplot_ref_for_trace(trace): pass return None + +_INITIAL_MAX_SUBPLOT_IDS = {**{subplot_type: 0 for subplot_type in _single_subplot_types}, "xaxis": 0, "yaxis": 0}