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

Two issues with the axes offset indicator #4445

Closed
anntzer opened this issue May 19, 2015 · 2 comments
Closed

Two issues with the axes offset indicator #4445

anntzer opened this issue May 19, 2015 · 2 comments

Comments

@anntzer
Copy link
Contributor

anntzer commented May 19, 2015

Consider:

plt.plot(10001 + np.arange(10), 10001 + np.arange(10))
plt.setp(plt.gca().get_yticklabels(), visible=False)
plt.show()

The x axis is labeled 0..9 + 1.0001e4. I'd suggest changing this to 1..10 + 1.0000e4, which is IMO much more legible.

The y axis doesn't show the tick labels, as expected, but the offset indicator ("+1.0001e4") is still there. setp(get_{x,y}ticklabels(), visible=False) is certainly a commonly used approach (e.g. by SubplotBase.label_outer()).
What I believe the correct solution, which is also set offsetText (which can be obtained by get_offset_text()) to invisible, is a bit obscure (and not mentioned in the docs).

@tacaswell
Copy link
Member

If you reach in and change the visibility of the individual Text objects, there is not much that we can do. I would argue that this behavior is actually a feature so users can flip individual tick labels on/off without affecting anything else.

The easiest way to turn off the tick labels on an axis (if you are not using sharing any axis) is

import matplotlib.ticker as mticker
ax.yaxis.set_major_formatter(mticker.NullFormatter ())

which removes both the labels and the offset label.

In the case of label_outer things are a bit trickier as there may be shared axes around so setting the NullFormatter will remove all of the ticklabels.

Can you add few lines needed in label_outer to also hide the offset text and a test for this?

Also: http://matplotlib.org/api/axis_api.html#matplotlib.axis.Axis.get_offset_text

@tacaswell tacaswell added this to the next point release milestone May 20, 2015
@anntzer
Copy link
Contributor Author

anntzer commented May 20, 2015

Sure, I understand and don't expect the API of get_xticklabels to be changed; my point about lack of mention in the docs was that I was hoping for some "FAQ: How do I get rid of all ticklabels? Answer: Set ticklabels and offsetText to not visible" (or better, as you mention it, "use NullFormatter").
If you go through the examples, many more are using the "set ticklabels to not visible" approach than the "use NullFormatter" approach, which also leads to the former being more often mentioned on StackOverflow & others.
I can have a look at label_outer.

anntzer added a commit to anntzer/matplotlib that referenced this issue May 20, 2015
@tacaswell tacaswell modified the milestones: next point release, proposed next point release Jul 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants