Skip to content
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

suggestion: set_xticklabels and set_yticklabels default to current labels #6795

Closed
chubukov opened this issue Jul 18, 2016 · 3 comments
Closed
Labels
Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues New feature
Milestone

Comments

@chubukov
Copy link

I often find myself writing a construction like this:

ax.set_xticklabels([x.get_text() for x in ax.get_xticklabels()],rotation=90)

This just looks ugly and it feels to me like this should have the same effect:

ax.set_xticklabels(rotation=90)

which would just require handling labels=None and defaulting to the current labels.

Or is there already a more idiomatic way to do this that I'm missing?

@Phlya
Copy link
Contributor

Phlya commented Jul 18, 2016

plt.setp(ax.xaxis.get_majorticklabels(), rotation=90) is probably more idiomatic?.. Definitely shorter.

@tacaswell tacaswell added this to the 2.1 (next point release) milestone Jul 20, 2016
@tacaswell tacaswell added Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues New feature labels Jul 20, 2016
@tacaswell
Copy link
Member

The Axis objects should probably be updated to include rotation as a valid tick parameter.

I think this will require updating mpl.axis._translate_tick_kw to allow rotation as a key + a test + a whats_new entry.

With those changes I think you will be able to do

ax.xaxis.set_tick_params(which='both', rotation=90)

@tacaswell
Copy link
Member

implemented by #6829

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues New feature
Projects
None yet
Development

No branches or pull requests

3 participants