Skip to content

earthpy.plot.plot_bands method ignores ax keyword argument if raster has multiple bands #796

@ahasha

Description

@ahasha

Describe the bug
earthpy.plot.plot_bands method ignores ax keyword argument if raster has multiple bands

To Reproduce
Steps to reproduce the behavior:

If raster is an array with raster.ndim > 2 and raster.shape[0] > 1, then the ax keyword
argument has no effect and the plot_bands method produces a new axes array. The user has
no access to the figure object to customize the plot.

import earthpy.plot as ep
import matplotlib.pyplot as plt

fig, axs = plt.subplots(3, 1)
ep.plot_bands(raster, ax=axs)

will produce an output that looks like

image

Expected behavior

Ideally, if an axis grid consistent with the number of bands is passed in the ax keyword argument, the method would use these axes objects as expected. If this is not feasible, an error message indicating that the ax keyword is not supported when multi-band arrays are provided is needed to avoid confusion.

**What Operating System Are you Running? **

  • Mac

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions