Skip to content

Commit 2c72779

Browse files
committed
Fix matplotlib missing get_offset_position crash
* Update matplotlib test versions
1 parent 294d743 commit 2c72779

File tree

6 files changed

+18
-7
lines changed

6 files changed

+18
-7
lines changed

Diff for: CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [UNRELEASED]
6+
7+
### Fixed
8+
- Repair crash on Matplotlib 3.8 related to get_offset_position [[#4372](https://github.com/plotly/plotly.py/pull/4372)],
9+
510
## [5.17.0] - 2023-09-15
611

712
### Updated

Diff for: packages/python/plotly/plotly/matplotlylib/mplexporter/exporter.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def process_transform(
9696

9797
code = "display"
9898
if ax is not None:
99-
for (c, trans) in [
99+
for c, trans in [
100100
("data", ax.transData),
101101
("axes", ax.transAxes),
102102
("figure", ax.figure.transFigure),
@@ -130,7 +130,7 @@ def crawl_ax(self, ax):
130130
self.draw_line(ax, line)
131131
for text in ax.texts:
132132
self.draw_text(ax, text)
133-
for (text, ttp) in zip(
133+
for text, ttp in zip(
134134
[ax.xaxis.label, ax.yaxis.label, ax.title],
135135
["xlabel", "ylabel", "title"],
136136
):
@@ -285,8 +285,14 @@ def draw_collection(
285285
"zorder": collection.get_zorder(),
286286
}
287287

288+
# TODO: When matplotlib's minimum version is bumped to 3.8, this can be
289+
# simplified since collection.get_offset_position no longer exists.
288290
offset_dict = {"data": "before", "screen": "after"}
289-
offset_order = offset_dict[collection.get_offset_position()]
291+
offset_order = (
292+
offset_dict[collection.get_offset_position()]
293+
if hasattr(collection, "get_offset_position")
294+
else "after"
295+
)
290296

291297
self.renderer.draw_path_collection(
292298
paths=processed_paths,

Diff for: packages/python/plotly/test_requirements/requirements_37_optional.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ scipy==1.2.3
1515
shapely==1.7.0
1616
geopandas==0.3.0
1717
pyshp==1.2.10
18-
matplotlib==2.2.3
18+
matplotlib==3.5.3
1919
scikit-image==0.14.4
2020
psutil==5.7.0
2121
kaleido

Diff for: packages/python/plotly/test_requirements/requirements_38_optional.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ scipy==1.6.2
1515
Shapely==1.7.1
1616
geopandas==0.9.0
1717
pyshp==2.1.3
18-
matplotlib==2.2.3
18+
matplotlib==3.7.3
1919
scikit-image==0.18.1
2020
psutil==5.7.0
2121
kaleido

Diff for: packages/python/plotly/test_requirements/requirements_39_optional.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ scipy==1.6.2
1515
Shapely==1.7.1
1616
geopandas==0.9.0
1717
pyshp==2.1.3
18-
matplotlib==2.2.3
18+
matplotlib==3.8.0
1919
scikit-image==0.18.1
2020
psutil==5.7.0
2121
kaleido

Diff for: packages/python/plotly/test_requirements/requirements_39_pandas_2_optional.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ scipy==1.6.2
1515
Shapely==1.7.1
1616
geopandas==0.9.0
1717
pyshp==2.1.3
18-
matplotlib==2.2.3
18+
matplotlib==3.8.0
1919
scikit-image==0.18.1
2020
psutil==5.7.0
2121
kaleido

0 commit comments

Comments
 (0)