Skip to content

Commit 8fc9c1d

Browse files
authored
Merge pull request #74 from physiopy/master
Resolve matplotlib deprecation issue
2 parents d31ebbf + a54d327 commit 8fc9c1d

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

peakdet/editor.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33

44
import functools
55

6+
import matplotlib
67
import matplotlib.pyplot as plt
78
import numpy as np
89
from loguru import logger
910
from matplotlib.widgets import SpanSelector
11+
from packaging.version import Version
1012

1113
from peakdet import operations, utils
1214

@@ -60,29 +62,36 @@ def __init__(self, data):
6062
delete = functools.partial(self.on_edit, method="delete")
6163
reject = functools.partial(self.on_edit, method="reject")
6264
insert = functools.partial(self.on_edit, method="insert")
65+
66+
# Check matplotlib version rectprops is deprecated with matplotlib 3.5.0 and then obsolete
67+
if Version(matplotlib.__version__) >= Version("3.5.0"):
68+
property_name = "props"
69+
else:
70+
property_name = "rectprops"
71+
6372
self.span2 = SpanSelector(
6473
self.ax,
6574
delete,
6675
"horizontal",
6776
button=1,
6877
useblit=True,
69-
rectprops=dict(facecolor="red", alpha=0.3),
78+
**{property_name: dict(facecolor="red", alpha=0.3)},
7079
)
7180
self.span1 = SpanSelector(
7281
self.ax,
7382
reject,
7483
"horizontal",
7584
button=2,
7685
useblit=True,
77-
rectprops=dict(facecolor="blue", alpha=0.3),
86+
**{property_name: dict(facecolor="blue", alpha=0.3)},
7887
)
7988
self.span3 = SpanSelector(
8089
self.ax,
8190
insert,
8291
"horizontal",
8392
button=3,
8493
useblit=True,
85-
rectprops=dict(facecolor="green", alpha=0.3),
94+
**{property_name: dict(facecolor="green", alpha=0.3)},
8695
)
8796

8897
self.plot_signals(False)

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ provides =
2121
[options]
2222
python_requires = >=3.6.1
2323
install_requires =
24-
matplotlib >=3.1.1, <=3.6.3, !=3.3.0rc1
24+
matplotlib >=3.1.1
2525
numpy >=1.9.3
2626
scipy
2727
loguru

0 commit comments

Comments
 (0)