Skip to content

Commit

Permalink
get the colorbar label via public methods (#4201)
Browse files Browse the repository at this point in the history
  • Loading branch information
keewis committed Jul 4, 2020
1 parent 87f671e commit 03c8562
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion xarray/tests/test_plot.py
Expand Up @@ -88,6 +88,13 @@ def easy_array(shape, start=0, stop=1):
return a.reshape(shape)


def get_colorbar_label(colorbar):
if colorbar.orientation == "vertical":
return colorbar.ax.get_ylabel()
else:
return colorbar.ax.get_xlabel()


@requires_matplotlib
class PlotTestCase:
@pytest.fixture(autouse=True)
Expand Down Expand Up @@ -1414,7 +1421,7 @@ def test_facetgrid_cbar_kwargs(self):

# catch contour case
if hasattr(g, "cbar"):
assert g.cbar._label == "test_label"
assert get_colorbar_label(g.cbar) == "test_label"

def test_facetgrid_no_cbar_ax(self):
a = easy_array((10, 15, 2, 3))
Expand Down

0 comments on commit 03c8562

Please sign in to comment.