diff --git a/act/plotting/xsectiondisplay.py b/act/plotting/xsectiondisplay.py index d989594c0c..0538e8d08d 100644 --- a/act/plotting/xsectiondisplay.py +++ b/act/plotting/xsectiondisplay.py @@ -75,6 +75,7 @@ def __init__(self, ds, subplot_shape=(1,), ds_name=None, **kwargs): super().__init__(ds, subplot_shape, ds_name, **kwargs) def set_subplot_to_map(self, subplot_index): + self.fig.delaxes(self.axes[subplot_index]) total_num_plots = self.axes.shape if len(total_num_plots) == 2: @@ -235,9 +236,9 @@ def plot_xsection( yc = y if x is None: - ax = my_dataarray.plot(ax=self.axes[subplot_index], **kwargs) + my_dataarray.plot(ax=self.axes[subplot_index], **kwargs) else: - ax = my_dataarray.plot(ax=self.axes[subplot_index], x=xc, y=yc, **kwargs) + my_dataarray.plot(ax=self.axes[subplot_index], x=xc, y=yc, **kwargs) the_coords = [the_keys for the_keys in my_dataarray.coords.keys()] if x is None: @@ -255,7 +256,7 @@ def plot_xsection( yrng = self.axes[subplot_index].get_ylim() self.set_yrng(yrng, subplot_index) del temp_ds - return ax + return self.axes[subplot_index] def plot_xsection_map( self, dsname, varname, subplot_index=(0,), coastlines=True, background=False, **kwargs @@ -290,7 +291,6 @@ def plot_xsection_map( raise ImportError( 'Cartopy needs to be installed in order to plot ' + 'cross sections on maps!' ) - self.set_subplot_to_map(subplot_index) self.plot_xsection(dsname, varname, subplot_index=subplot_index, **kwargs) xlims = self.xrng[subplot_index].flatten() diff --git a/tests/plotting/baseline/test_xsection_plot_map.png b/tests/plotting/baseline/test_xsection_plot_map.png index 3ae6491098..9165ad70c7 100644 Binary files a/tests/plotting/baseline/test_xsection_plot_map.png and b/tests/plotting/baseline/test_xsection_plot_map.png differ