-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
ax.set_xticklabels([]) for categorical plots is broken in 3.3.0rc1 #17736
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
Comments
I guess that needs better documentation. OTOH I’m not sure or not if we should support what you are after here. As also pointed out in the stackoverflow thread you should use a NullFormatter to do this cleanly. Just passing an empty list to the fixed formatter seems like something that worked by accident rather than a conscious API decision Ping @efiring. |
Special-casing the empty list, possibly with a Deprecation, seems like a reasonable option here. I can imagine that the empty list idiom might be common; it's logical, and easy to use. |
We have 5 usages of It's also used via IMHO we should continue to support the empty list. |
May I ask how this problem is resolved in matplotlib 3.3.2? "The number of FixedLocator locations" Thanks |
If you are still having this issue in 3.4.x please open a new issue with a reproducible example... Thanks! |
On 3.3.2 you can try
|
I resolved this issue by adding 1 to the numpy.arange function. panel1.set_xticks(np.arange(0, len(xlabels)+1, 1)) If there is only 1 xlabel, xticks must be [0 1] not [0]. Therefore, code below does not give error, since it places the tick label at position 0.5 panel1.set_xticklabels([]) |
Bug report
Bug summary
#17266 requires tick labels set by
FixedFormatter
to be equal to the ticks set byFixedLocator
.FixedLocator
is used in many cases where categorical data is plotted, e.g.bar
andbox plot
. A way of removing all tick labels (while maintaining ticks and gridlines) is to doax.set_xticklabels([])
orax.set_yticklabels([])
, by passing just an empty list. This works on 3.2.2, but raises aValueError
with 3.3.0rc1.The new behavior is not mentioned in the "What's new?" section of 3.3.0rc1. I suspect this may break existing code, as it broke seaborn and this stackoverflow thread seems very popular.
Code for reproduction
Actual outcome
Expected outcome
Unset tick labels but not error out, or raise a deprecation warning that this won't be possible in a future release.
Matplotlib version
print(matplotlib.get_backend())
): MacOSXInstalled using pip
The text was updated successfully, but these errors were encountered: