Skip to content

Commit 0ea6ac5

Browse files
committed
redoing matplotlib deprecation fix
1 parent d31ebbf commit 0ea6ac5

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

peakdet/editor.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,29 +60,36 @@ def __init__(self, data):
6060
delete = functools.partial(self.on_edit, method="delete")
6161
reject = functools.partial(self.on_edit, method="reject")
6262
insert = functools.partial(self.on_edit, method="insert")
63+
64+
# Check matplotlib version rectprops is deprecated with matplotlib 3.5.0 and then obsolete
65+
if matplotlib.__version__ >= '3.5.0':
66+
property_name = 'props'
67+
else:
68+
property_name = 'rectprops'
69+
6370
self.span2 = SpanSelector(
6471
self.ax,
6572
delete,
6673
"horizontal",
6774
button=1,
6875
useblit=True,
69-
rectprops=dict(facecolor="red", alpha=0.3),
76+
**{property_name: dict(facecolor='red', alpha=0.3)},
7077
)
7178
self.span1 = SpanSelector(
7279
self.ax,
7380
reject,
7481
"horizontal",
7582
button=2,
7683
useblit=True,
77-
rectprops=dict(facecolor="blue", alpha=0.3),
84+
**{property_name: dict(facecolor='blue', alpha=0.3)},
7885
)
7986
self.span3 = SpanSelector(
8087
self.ax,
8188
insert,
8289
"horizontal",
8390
button=3,
8491
useblit=True,
85-
rectprops=dict(facecolor="green", alpha=0.3),
92+
**{property_name: dict(facecolor='green', alpha=0.3)},
8693
)
8794

8895
self.plot_signals(False)

0 commit comments

Comments
 (0)