Skip to content

Commit

Permalink
FIX: A fix for duplicate axes for xsectiondisplay. (ARM-DOE#817)
Browse files Browse the repository at this point in the history
* FIX: A fix for duplicate axes for xsectiondisplay.

* STY: PEP8 fix.
  • Loading branch information
zssherman authored Apr 4, 2024
1 parent f97a0d3 commit 6a5223b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions act/plotting/xsectiondisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down
Binary file modified tests/plotting/baseline/test_xsection_plot_map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6a5223b

Please sign in to comment.