|
3 | 3 |
|
4 | 4 | import functools |
5 | 5 |
|
| 6 | +import matplotlib |
6 | 7 | import matplotlib.pyplot as plt |
7 | 8 | import numpy as np |
8 | 9 | from loguru import logger |
9 | 10 | from matplotlib.widgets import SpanSelector |
| 11 | +from packaging.version import Version |
10 | 12 |
|
11 | 13 | from peakdet import operations, utils |
12 | 14 |
|
@@ -60,29 +62,36 @@ def __init__(self, data): |
60 | 62 | delete = functools.partial(self.on_edit, method="delete") |
61 | 63 | reject = functools.partial(self.on_edit, method="reject") |
62 | 64 | 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 | + |
63 | 72 | self.span2 = SpanSelector( |
64 | 73 | self.ax, |
65 | 74 | delete, |
66 | 75 | "horizontal", |
67 | 76 | button=1, |
68 | 77 | useblit=True, |
69 | | - rectprops=dict(facecolor="red", alpha=0.3), |
| 78 | + **{property_name: dict(facecolor="red", alpha=0.3)}, |
70 | 79 | ) |
71 | 80 | self.span1 = SpanSelector( |
72 | 81 | self.ax, |
73 | 82 | reject, |
74 | 83 | "horizontal", |
75 | 84 | button=2, |
76 | 85 | useblit=True, |
77 | | - rectprops=dict(facecolor="blue", alpha=0.3), |
| 86 | + **{property_name: dict(facecolor="blue", alpha=0.3)}, |
78 | 87 | ) |
79 | 88 | self.span3 = SpanSelector( |
80 | 89 | self.ax, |
81 | 90 | insert, |
82 | 91 | "horizontal", |
83 | 92 | button=3, |
84 | 93 | useblit=True, |
85 | | - rectprops=dict(facecolor="green", alpha=0.3), |
| 94 | + **{property_name: dict(facecolor="green", alpha=0.3)}, |
86 | 95 | ) |
87 | 96 |
|
88 | 97 | self.plot_signals(False) |
|
0 commit comments