|
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 |
|
@@ -61,35 +63,35 @@ def __init__(self, data): |
61 | 63 | reject = functools.partial(self.on_edit, method="reject") |
62 | 64 | insert = functools.partial(self.on_edit, method="insert") |
63 | 65 |
|
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' |
| 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" |
67 | 69 | else: |
68 | | - property_name = 'rectprops' |
| 70 | + property_name = "rectprops" |
69 | 71 |
|
70 | 72 | self.span2 = SpanSelector( |
71 | 73 | self.ax, |
72 | 74 | delete, |
73 | 75 | "horizontal", |
74 | 76 | button=1, |
75 | 77 | useblit=True, |
76 | | - **{property_name: dict(facecolor='red', alpha=0.3)}, |
| 78 | + **{property_name: dict(facecolor="red", alpha=0.3)}, |
77 | 79 | ) |
78 | 80 | self.span1 = SpanSelector( |
79 | 81 | self.ax, |
80 | 82 | reject, |
81 | 83 | "horizontal", |
82 | 84 | button=2, |
83 | 85 | useblit=True, |
84 | | - **{property_name: dict(facecolor='blue', alpha=0.3)}, |
| 86 | + **{property_name: dict(facecolor="blue", alpha=0.3)}, |
85 | 87 | ) |
86 | 88 | self.span3 = SpanSelector( |
87 | 89 | self.ax, |
88 | 90 | insert, |
89 | 91 | "horizontal", |
90 | 92 | button=3, |
91 | 93 | useblit=True, |
92 | | - **{property_name: dict(facecolor='green', alpha=0.3)}, |
| 94 | + **{property_name: dict(facecolor="green", alpha=0.3)}, |
93 | 95 | ) |
94 | 96 |
|
95 | 97 | self.plot_signals(False) |
|
0 commit comments