Skip to content

Commit 46b45c6

Browse files
author
dcherian
committed
kwarg tests.
1 parent 28ae492 commit 46b45c6

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

xarray/tests/test_plot.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,26 @@ def setUp(self):
9494
def test1d(self):
9595
self.darray[:, 0, 0].plot()
9696

97-
def test2dline(self):
97+
def test_2d_line(self):
9898
self.darray[:, :, 0].plot.line()
9999

100+
def test_2d_line_accepts_legend_kw(self):
101+
self.darray[:, :, 0].plot.line(add_legend=False)
102+
self.assertFalse(plt.gca().get_legend())
103+
plt.cla()
104+
self.darray[:, :, 0].plot.line(add_legend=True)
105+
self.assertTrue(plt.gca().get_legend())
106+
# check whether legend title is set
107+
self.assertTrue(plt.gca().get_legend().get_title().get_text()
108+
== 'dim_0')
109+
110+
def test_2d_line_accepts_x_kw(self):
111+
self.darray[:, :, 0].plot.line(x='dim_0')
112+
self.assertTrue(plt.gca().get_xlabel() == 'dim_0')
113+
plt.cla()
114+
self.darray[:, :, 0].plot.line(x='dim_1')
115+
self.assertTrue(plt.gca().get_xlabel() == 'dim_1')
116+
100117
def test_2d_before_squeeze(self):
101118
a = DataArray(easy_array((1, 5)))
102119
a.plot()

0 commit comments

Comments
 (0)