4343 q_to_tth ,
4444 tth_to_q ,
4545)
46+ from hexrdgui .utils .matplotlib import remove_artist
4647from hexrdgui .utils .tth_distortion import apply_tth_distortion_if_needed
4748from hexrdgui .waterfall_plot import WaterfallPlotDialog
4849
@@ -232,10 +233,10 @@ def clear(self):
232233 self .clear_figure ()
233234
234235 def clear_figure (self ):
236+ self .remove_all_overlay_artists ()
235237 self .figure .clear ()
236238 self .raw_axes .clear ()
237239 self .axes_images .clear ()
238- self .remove_all_overlay_artists ()
239240 self .clear_azimuthal_integral_axis ()
240241 self .mode = None
241242
@@ -248,24 +249,24 @@ def clear_azimuthal_integral_axis(self):
248249
249250 def clear_wppf_plot (self ):
250251 if self .wppf_plot :
251- self .wppf_plot . remove ( )
252+ remove_artist ( self .wppf_plot )
252253 self .wppf_plot = None
253254
254255 if self .wppf_background_plot :
255- self .wppf_background_plot . remove ( )
256+ remove_artist ( self .wppf_background_plot )
256257 self .wppf_background_plot = None
257258
258259 if self .wppf_amorphous_plot :
259- self .wppf_amorphous_plot . remove ( )
260+ remove_artist ( self .wppf_amorphous_plot )
260261 self .wppf_amorphous_plot = None
261262
262263 if self .wppf_difference_plot :
263- self .wppf_difference_plot . remove ( )
264+ remove_artist ( self .wppf_difference_plot )
264265 self .wppf_difference_plot = None
265266
266267 def clear_auto_picked_data_artists (self ):
267268 while self .auto_picked_data_artists :
268- self .auto_picked_data_artists .pop (0 ). remove ( )
269+ remove_artist ( self .auto_picked_data_artists .pop (0 ))
269270
270271 def load_images (self , image_names ):
271272 HexrdConfig ().emit_update_status_bar ('Loading image view...' )
@@ -851,7 +852,7 @@ def update_overlays(self):
851852
852853 def clear_detector_borders (self ):
853854 while self .cached_detector_borders :
854- self .cached_detector_borders .pop (0 ). remove ( )
855+ remove_artist ( self .cached_detector_borders .pop (0 ))
855856
856857 self .draw_idle ()
857858
@@ -875,7 +876,7 @@ def draw_detector_borders(self):
875876
876877 def clear_stereo_border_artists (self ):
877878 while self .stereo_border_artists :
878- self .stereo_border_artists .pop (0 ). remove ( )
879+ remove_artist ( self .stereo_border_artists .pop (0 ))
879880
880881 self .draw_idle ()
881882
@@ -916,7 +917,7 @@ def draw_auto_picked_data(self):
916917
917918 def clear_saturation (self ):
918919 for t in self .saturation_texts :
919- t . remove ( )
920+ remove_artist ( t )
920921 self .saturation_texts .clear ()
921922 self .draw_idle ()
922923
@@ -981,7 +982,7 @@ def compute_saturation_and_size(detector_name):
981982
982983 def clear_beam_marker (self ):
983984 while self .beam_marker_artists :
984- self .beam_marker_artists .pop (0 ). remove ( )
985+ remove_artist ( self .beam_marker_artists .pop (0 ))
985986
986987 def update_beam_marker (self ):
987988 self .clear_beam_marker ()
@@ -1766,7 +1767,7 @@ def clear_azimuthal_overlay_artists(self):
17661767 while self .azimuthal_overlay_artists :
17671768 item = self .azimuthal_overlay_artists .pop (0 )
17681769 for artist in item ['artists' ].values ():
1769- artist . remove ( )
1770+ remove_artist ( artist )
17701771
17711772 def save_azimuthal_plot (self ):
17721773 if self .mode != ViewType .polar :
@@ -1835,7 +1836,7 @@ def update_azimuthal_plot_overlays(self):
18351836 self .azimuthal_integral_axis .legend ()
18361837 elif (axis := self .azimuthal_integral_axis ) and axis .get_legend ():
18371838 # Only remove the legend if the axis exists and it has a legend
1838- axis .get_legend (). remove ( )
1839+ remove_artist ( axis .get_legend ())
18391840 self .draw_idle ()
18401841
18411842 def update_azimuthal_integral_plot (self ):
@@ -2268,7 +2269,7 @@ def update_mask_boundaries(self, axis):
22682269
22692270 def clear_mask_boundaries (self ):
22702271 for artist in self ._mask_boundary_artists :
2271- artist . remove ( )
2272+ remove_artist ( artist )
22722273
22732274 self ._mask_boundary_artists .clear ()
22742275
0 commit comments