diff --git a/doc/api/next_api_changes/deprecations/20753-AL.rst b/doc/api/next_api_changes/deprecations/20753-AL.rst new file mode 100644 index 000000000000..75b989f5c658 --- /dev/null +++ b/doc/api/next_api_changes/deprecations/20753-AL.rst @@ -0,0 +1,4 @@ +Case-insensitive scales +~~~~~~~~~~~~~~~~~~~~~~~ +Previously, scales could be set case-insensitively (e.g. ``set_xscale("LoG")``). +This is deprecated; all builtin scales use lowercase names. diff --git a/lib/matplotlib/scale.py b/lib/matplotlib/scale.py index 62dc5192a30d..180906106747 100644 --- a/lib/matplotlib/scale.py +++ b/lib/matplotlib/scale.py @@ -588,9 +588,13 @@ def scale_factory(scale, axis, **kwargs): scale : {%(names)s} axis : `matplotlib.axis.Axis` """ - scale = scale.lower() - _api.check_in_list(_scale_mapping, scale=scale) - return _scale_mapping[scale](axis, **kwargs) + if scale != scale.lower(): + _api.warn_deprecated( + "3.5", message="Support for case-insensitive scales is deprecated " + "since %(since)s and support will be removed %(removal)s.") + scale = scale.lower() + scale_cls = _api.check_getitem(_scale_mapping, scale=scale) + return scale_cls(axis, **kwargs) if scale_factory.__doc__: