diff --git a/packages/python/plotly/plotly/matplotlylib/mplexporter/exporter.py b/packages/python/plotly/plotly/matplotlylib/mplexporter/exporter.py index 9824d274c1c..0e048793b5b 100644 --- a/packages/python/plotly/plotly/matplotlylib/mplexporter/exporter.py +++ b/packages/python/plotly/plotly/matplotlylib/mplexporter/exporter.py @@ -285,8 +285,12 @@ def draw_collection( "zorder": collection.get_zorder(), } + # TODO: When matplotlib's minimum version is bumped to 3.8, this can be + # simplified since collection.get_offset_position no longer exists. offset_dict = {"data": "before", "screen": "after"} - offset_order = offset_dict[collection.get_offset_position()] + offset_order = (offset_dict[collection.get_offset_position()] + if hasattr(collection, "get_offset_position") + else "after") self.renderer.draw_path_collection( paths=processed_paths,