-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add x,y kwargs for plot.line(). #1926
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
Changes from 5 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,14 +91,44 @@ def setUp(self): | |
def test1d(self): | ||
self.darray[:, 0, 0].plot() | ||
|
||
with raises_regex(ValueError, 'dimension'): | ||
with raises_regex(ValueError, 'None'): | ||
self.darray[:, 0, 0].plot(x='dim_1') | ||
|
||
def test_1d_x_y_kw(self): | ||
z = np.arange(10) | ||
da = DataArray(np.cos(z), dims=['z'], coords=[z], name='f') | ||
|
||
xy = [[None, None], | ||
[None, 'z'], | ||
['z', None]] | ||
|
||
f, ax = plt.subplots(2, 4) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You only have two cases now, so no need for 2x4 subplots. |
||
|
||
for aa, (x, y) in enumerate(xy): | ||
da.plot(x=x, y=y, ax=ax.flat[aa]) | ||
ax.flat[aa].set_title('x=' + str(x) + ' | ' + 'y=' + str(y)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any point to this line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. I copied the test over from my debugging plots. I'll remove it (I assume you mean the |
||
|
||
with raises_regex(ValueError, 'cannot'): | ||
da.plot(x='z', y='z') | ||
|
||
with raises_regex(ValueError, 'None'): | ||
da.plot(x='f', y='z') | ||
|
||
with raises_regex(ValueError, 'None'): | ||
da.plot(x='z', y='f') | ||
|
||
def test_2d_line(self): | ||
with raises_regex(ValueError, 'hue'): | ||
self.darray[:, :, 0].plot.line() | ||
|
||
self.darray[:, :, 0].plot.line(hue='dim_1') | ||
self.darray[:, :, 0].plot.line(x='dim_1') | ||
self.darray[:, :, 0].plot.line(y='dim_1') | ||
self.darray[:, :, 0].plot.line(x='dim_0', hue='dim_1') | ||
self.darray[:, :, 0].plot.line(y='dim_0', hue='dim_1') | ||
|
||
with raises_regex(ValueError, 'cannot'): | ||
self.darray[:, :, 0].plot.line(x='dim_1', y='dim_0', hue='dim_1') | ||
|
||
def test_2d_line_accepts_legend_kw(self): | ||
self.darray[:, :, 0].plot.line(x='dim_0', add_legend=False) | ||
|
@@ -279,6 +309,10 @@ def test_xlabel_is_index_name(self): | |
self.darray.plot() | ||
assert 'period' == plt.gca().get_xlabel() | ||
|
||
def test_no_label_name_on_x_axis(self): | ||
self.darray.plot(y='period') | ||
self.assertEqual('', plt.gca().get_xlabel()) | ||
|
||
def test_no_label_name_on_y_axis(self): | ||
self.darray.plot() | ||
assert '' == plt.gca().get_ylabel() | ||
|
@@ -288,6 +322,11 @@ def test_ylabel_is_data_name(self): | |
self.darray.plot() | ||
assert self.darray.name == plt.gca().get_ylabel() | ||
|
||
def test_xlabel_is_data_name(self): | ||
self.darray.name = 'temperature' | ||
self.darray.plot(y='period') | ||
self.assertEqual(self.darray.name, plt.gca().get_xlabel()) | ||
|
||
def test_format_string(self): | ||
self.darray.plot.line('ro') | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably say something like "The other coordinate plots values from the DataArray on which this plot method is called."