From 88310e1dee5953efc414a7175d484979d6f3d808 Mon Sep 17 00:00:00 2001 From: Dmitri Gavrilov Date: Mon, 19 Aug 2024 14:35:42 -0400 Subject: [PATCH 1/3] FIX: Hack that makes PyXRF work with MPL 3.9.1 --- pyxrf/model/lineplot.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/pyxrf/model/lineplot.py b/pyxrf/model/lineplot.py index 53a8770c..fffadb11 100644 --- a/pyxrf/model/lineplot.py +++ b/pyxrf/model/lineplot.py @@ -726,14 +726,15 @@ def plot_selected_energy_range_original(self, *, e_low=None, e_high=None): # Remove the plot if it exists if self.plot_energy_barh in self._ax.collections: self.plot_energy_barh.remove() + self.plot_energy_barh.remove() # Create the new plot (based on new parameters if necessary - self.plot_energy_barh = PolyCollection.span_where( - x_v, ymin=y_min, ymax=y_max, where=ss, facecolor="white", edgecolor="yellow", alpha=1 - ) - # self.plot_energy_barh = self._ax.fill_between( - # x_v, y1=y_min, y2=y_max, where=ss, facecolor="white", edgecolor="yellow", alpha=1 + # self.plot_energy_barh = PolyCollection.span_where( + # x_v, ymin=y_min, ymax=y_max, where=ss, facecolor="white", edgecolor="yellow", alpha=1 # ) + self.plot_energy_barh = self._ax.fill_between( + x_v, y1=y_min, y2=y_max, where=ss, facecolor="white", edgecolor="yellow", alpha=1 + ) self._ax.add_collection(self.plot_energy_barh) def plot_multi_exp_data(self): @@ -1473,14 +1474,15 @@ def plot_selected_energy_range(self, *, axes, barh_existing, e_low=None, e_high= # Remove the plot if it exists if barh_existing in axes.collections: barh_existing.remove() + barh_existing.remove() # Create the new plot (based on new parameters if necessary - barh_new = PolyCollection.span_where( - x_v, ymin=y_min, ymax=y_max, where=ss, facecolor="white", edgecolor="yellow", alpha=1 - ) - # barh_new = axes.fill_between( - # x_v, y1=y_min, y2=y_max, where=ss, facecolor="white", edgecolor="yellow", alpha=1 + # barh_new = PolyCollection.span_where( + # x_v, ymin=y_min, ymax=y_max, where=ss, facecolor="white", edgecolor="yellow", alpha=1 # ) + barh_new = axes.fill_between( + x_v, y1=y_min, y2=y_max, where=ss, facecolor="white", edgecolor="yellow", alpha=1 + ) axes.add_collection(barh_new) return barh_new From fa57de005cf4653140fd482e057dbb979fdbfda5 Mon Sep 17 00:00:00 2001 From: Dmitri Gavrilov Date: Mon, 19 Aug 2024 16:49:44 -0400 Subject: [PATCH 2/3] FIX: fix for deprecated 'span_where' (replaced by 'fill_between') --- pyxrf/model/lineplot.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pyxrf/model/lineplot.py b/pyxrf/model/lineplot.py index fffadb11..504e949b 100644 --- a/pyxrf/model/lineplot.py +++ b/pyxrf/model/lineplot.py @@ -726,16 +726,15 @@ def plot_selected_energy_range_original(self, *, e_low=None, e_high=None): # Remove the plot if it exists if self.plot_energy_barh in self._ax.collections: self.plot_energy_barh.remove() - self.plot_energy_barh.remove() # Create the new plot (based on new parameters if necessary # self.plot_energy_barh = PolyCollection.span_where( # x_v, ymin=y_min, ymax=y_max, where=ss, facecolor="white", edgecolor="yellow", alpha=1 # ) + #self._ax.add_collection(self.plot_energy_barh) self.plot_energy_barh = self._ax.fill_between( x_v, y1=y_min, y2=y_max, where=ss, facecolor="white", edgecolor="yellow", alpha=1 ) - self._ax.add_collection(self.plot_energy_barh) def plot_multi_exp_data(self): while len(self.plot_exp_list): @@ -1474,16 +1473,15 @@ def plot_selected_energy_range(self, *, axes, barh_existing, e_low=None, e_high= # Remove the plot if it exists if barh_existing in axes.collections: barh_existing.remove() - barh_existing.remove() # Create the new plot (based on new parameters if necessary # barh_new = PolyCollection.span_where( # x_v, ymin=y_min, ymax=y_max, where=ss, facecolor="white", edgecolor="yellow", alpha=1 # ) + #axes.add_collection(barh_new) barh_new = axes.fill_between( x_v, y1=y_min, y2=y_max, where=ss, facecolor="white", edgecolor="yellow", alpha=1 ) - axes.add_collection(barh_new) return barh_new From d742561a60c25a86e1ed0b2d1096bf09a4cd8fb6 Mon Sep 17 00:00:00 2001 From: Dmitri Gavrilov Date: Mon, 19 Aug 2024 16:54:46 -0400 Subject: [PATCH 3/3] STY: fixed formatting --- pyxrf/model/lineplot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyxrf/model/lineplot.py b/pyxrf/model/lineplot.py index 504e949b..013a6ba6 100644 --- a/pyxrf/model/lineplot.py +++ b/pyxrf/model/lineplot.py @@ -731,7 +731,7 @@ def plot_selected_energy_range_original(self, *, e_low=None, e_high=None): # self.plot_energy_barh = PolyCollection.span_where( # x_v, ymin=y_min, ymax=y_max, where=ss, facecolor="white", edgecolor="yellow", alpha=1 # ) - #self._ax.add_collection(self.plot_energy_barh) + # self._ax.add_collection(self.plot_energy_barh) self.plot_energy_barh = self._ax.fill_between( x_v, y1=y_min, y2=y_max, where=ss, facecolor="white", edgecolor="yellow", alpha=1 ) @@ -1478,7 +1478,7 @@ def plot_selected_energy_range(self, *, axes, barh_existing, e_low=None, e_high= # barh_new = PolyCollection.span_where( # x_v, ymin=y_min, ymax=y_max, where=ss, facecolor="white", edgecolor="yellow", alpha=1 # ) - #axes.add_collection(barh_new) + # axes.add_collection(barh_new) barh_new = axes.fill_between( x_v, y1=y_min, y2=y_max, where=ss, facecolor="white", edgecolor="yellow", alpha=1 )