Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename fig= to figure= in TiledDataset.plot #509

Merged
merged 3 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion changelog/491.feature.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Add a ``fig=`` keyword argument to `TiledDataset.plot` and make it default to the current figure.
Add a ``figure=`` keyword argument to `TiledDataset.plot` and make it default to the current figure.
20 changes: 10 additions & 10 deletions dkist/dataset/tiled_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
ylabel = coord.get_axislabel() or coord._get_default_axislabel()
return (xlabel, ylabel)

def plot(self, slice_index, share_zscale=False, fig=None, **kwargs):
def plot(self, slice_index, share_zscale=False, figure=None, **kwargs):
"""
Plot a slice of each tile in the TiledDataset

Expand All @@ -181,32 +181,32 @@
Determines whether the color scale of the plots should be calculated
independently (``False``) or shared across all plots (``True``).
Defaults to False
fig : `matplotlib.figure.Figure`
figure : `matplotlib.figure.Figure`
A figure to use for the plot. If not specified the current pyplot
figure will be used, or a new one created.
"""
if isinstance(slice_index, int):
slice_index = (slice_index,)
vmin, vmax = np.inf, 0

if fig is None:
fig = plt.gcf()
if figure is None:
figure = plt.gcf()

Check warning on line 193 in dkist/dataset/tiled_dataset.py

View check run for this annotation

Codecov / codecov/patch

dkist/dataset/tiled_dataset.py#L192-L193

Added lines #L192 - L193 were not covered by tests

tiles = self.slice_tiles[slice_index].flat
for i, tile in enumerate(tiles):
ax = fig.add_subplot(self.shape[0], self.shape[1], i+1, projection=tile.wcs)
ax = figure.add_subplot(self.shape[0], self.shape[1], i+1, projection=tile.wcs)

Check warning on line 197 in dkist/dataset/tiled_dataset.py

View check run for this annotation

Codecov / codecov/patch

dkist/dataset/tiled_dataset.py#L197

Added line #L197 was not covered by tests
tile.plot(axes=ax, **kwargs)
if i == 0:
xlabel, ylabel = self._get_axislabels(ax)
fig.supxlabel(xlabel, y=0.05)
fig.supylabel(ylabel, x=0.05)
figure.supxlabel(xlabel, y=0.05)
figure.supylabel(ylabel, x=0.05)

Check warning on line 202 in dkist/dataset/tiled_dataset.py

View check run for this annotation

Codecov / codecov/patch

dkist/dataset/tiled_dataset.py#L201-L202

Added lines #L201 - L202 were not covered by tests
axmin, axmax = ax.get_images()[0].get_clim()
vmin = axmin if axmin < vmin else vmin
vmax = axmax if axmax > vmax else vmax
ax.set_ylabel(" ")
ax.set_xlabel(" ")
if share_zscale:
for ax in fig.get_axes():
for ax in figure.get_axes():

Check warning on line 209 in dkist/dataset/tiled_dataset.py

View check run for this annotation

Codecov / codecov/patch

dkist/dataset/tiled_dataset.py#L209

Added line #L209 was not covered by tests
ax.get_images()[0].set_clim(vmin, vmax)
title = f"{self.inventory['instrumentName']} Dataset ({self.inventory['datasetId']}) at "
for i, (coord, val) in enumerate(list(tiles[0].global_coords.items())[::-1]):
Expand All @@ -216,8 +216,8 @@
val = val.symbol
title += f"{coord} {val}" + (", " if i != len(slice_index)-1 else " ")
title += f"(slice={(slice_index if len(slice_index) > 1 else slice_index[0])})".replace("slice(None, None, None)", ":")
fig.suptitle(title, y=0.95)
return fig
figure.suptitle(title, y=0.95)
return figure

Check warning on line 220 in dkist/dataset/tiled_dataset.py

View check run for this annotation

Codecov / codecov/patch

dkist/dataset/tiled_dataset.py#L219-L220

Added lines #L219 - L220 were not covered by tests

@property
def slice_tiles(self):
Expand Down
Loading