-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
plotting with index of objects should use FixedLocator
#7612
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 believe the change should be made in this method of the https://github.com/pydata/pandas/blob/master/pandas/tools/plotting.py#L1045 |
closing as stale. pls reopen if still an issue. |
This is still a bug and should be re-opened. |
When someone tries to fix this, make sure to test whether #2980, #11465 and #15912 are then solved. @TomAugspurger @sinhrks do you have an idea where this should best be handled? Somewhere in |
Yeah, |
FYI: This still appears to be an issue and drove me crazy till I found this! |
So I think i found the place where to put the change suggested by @tacaswell, and it fix #7612, #15912, #22334. |
Separate the test for pandas-dev#7612 and pandas-dev#22334, that are about string index, and test for pandas-dev#15912, about multiindex.
As pointed out here (https://stackoverflow.com/questions/24468333/set-xlim-for-pandas-matplotlib-where-index-is-string/24477138#24477138) if the index of a data frame is objects (that is not, the index obviously convertible to scalars and the data is being plotted against
range(len(df))
), the ticklabels are set to be string representations of the objects (I presume viaset_xticklabels
) but the locator is still aAutoLocator
which means if you change the xlimits or pan/zoom the axes, the ticklabels become de-coupled from the data.A solution is to also use a fixed locator which will pin the ticks to only be on the index locations.
I can make changes to the code if someone points me to where the relevant section is.
The text was updated successfully, but these errors were encountered: