Skip to content

Additional axis kwargs #2294

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

Merged
merged 11 commits into from
Jul 31, 2018
Merged

Additional axis kwargs #2294

merged 11 commits into from
Jul 31, 2018

Conversation

dcherian
Copy link
Contributor

  • Closes Add axis scaling kwargs to DataArray.plot() #2224 (remove if there is no corresponding issue, which should only be the case for minor changes)
  • Tests added (for all bug fixes or enhancements)
  • Tests passed (for all non-documentation changes)
  • Fully documented, including whats-new.rst for all changes and api.rst for new API (remove if this change should not be visible to users, e.g., if it is an internal clean-up, or if this is part of a larger project that will be documented later)

This PR adds support for xscale, yscale, xticks, yticks, xlim, ylim kwargs following discussion in #2224 and the Pandas API (https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.plot.html#pandas.DataFrame.plot).

Haven't added FacetGrid support yet. I'll get to that soon.

da.plot(xincrease=xincrease)
assert(plt.gca().xaxis_inverted() == (not xincrease))

@pytest.mark.parametrize('da', test_da_list)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

F811 redefinition of unused 'test_xincrease_kwarg' from line 1686

elif not xincrease:
ax.set_xlim(sorted(ax.get_xlim(), reverse=True))
elif xincrease and ax.xaxis_inverted():
ax.invert_xaxis()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why we weren't using these methods earlier?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so!

if np.issubdtype(xval.dtype, np.datetime64):
ax.get_figure().autofmt_xdate()
for xlabels in ax.get_xticklabels():
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed this bit in an older PR.

Copy link
Member

@fmaussion fmaussion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, thanks! LGTM pending the tests are passing

elif not xincrease:
ax.set_xlim(sorted(ax.get_xlim(), reverse=True))
elif xincrease and ax.xaxis_inverted():
ax.invert_xaxis()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so!

def _update_axes_limits(ax, xincrease, yincrease):
def _update_axes(ax, xincrease, yincrease,
xscale=None, yscale=None,
xticks=None, yticks=None, xlim=None, ylim=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aesthetic nit: linebreak after yticks=None,?

def test_xincrease_kwarg(self, da, xincrease):
plt.clf()
da.plot(xincrease=xincrease)
assert(plt.gca().xaxis_inverted() == (not xincrease))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't even know if it's worth fixing here, but assert is a statement, not a function. So you can write assert something rather than assert(something).

@fmaussion
Copy link
Member

As always for plotting functionalities, an example in the gallery would be welcome! This can be done in a subsequent PR of course.

@shoyer
Copy link
Member

shoyer commented Jul 31, 2018

This looks good to me. @dcherian do you want to do the honors and merge?

@dcherian dcherian merged commit 603911d into pydata:master Jul 31, 2018
@dcherian
Copy link
Contributor Author

Woot. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add axis scaling kwargs to DataArray.plot()
4 participants