Skip to content

QST: use and breadth of x_compat=True #45367

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

Closed
2 tasks done
ptoche opened this issue Jan 14, 2022 · 4 comments
Closed
2 tasks done

QST: use and breadth of x_compat=True #45367

ptoche opened this issue Jan 14, 2022 · 4 comments
Labels
Needs Triage Issue that has not been reviewed by a pandas team member Usage Question

Comments

@ptoche
Copy link

ptoche commented Jan 14, 2022

Research

  • I have searched the [pandas] tag on StackOverflow for similar questions.

  • I have asked my usage related question on StackOverflow.

Link to question on StackOverflow

https://stackoverflow.com/questions/70707996/matplotlib-horizontal-labels-as-style?noredirect=1#comment125004119_70707996

Question about pandas

If I understand correctly, x_compat=True allows one to have access to matplotlib's date formatters and disables some of pandas's date formatting. However, it has no effect on rotation (or rot in pandas parlance). My question is whether one would expect x_compat=True to also disable the rotation (that is, set it to 0). In other words, I'm not clear on how much of the date formatting x_compat=True is expected to "return" to the matplotlib default. Was it a design decision?

@ptoche ptoche added Needs Triage Issue that has not been reviewed by a pandas team member Usage Question labels Jan 14, 2022
@MarcoGorelli
Copy link
Member

My question is whether one would expect x_compat=True to also disable the rotation (that is, set it to 0)

Not sure I understand the question - doesn't x_compat=True result in rotated labels? Can you show an example please?

@ptoche
Copy link
Author

ptoche commented Jan 14, 2022

Thanks for your question!

Well I may be misunderstanding. Here's what I thought happened: with df.plot() a number of default are set, including handling of dates and rotating long dates such as "2021-01-01" by 30 degrees, but the x_compat=True flag allows the user to disable these defaults and call the matplotlib locators and formatters. Am I misunderstanding?

Setting x_compat=True keeps the rotation at 30 degrees, when I expected it to be reset to the matlolib default of 0 degrees.

I'm currently setting the rotation to 0 inside the plot call, but I would have liked for it to have been a default. Not a big deal.

@MarcoGorelli
Copy link
Member

MarcoGorelli commented Jan 14, 2022

I think x_compat is more about tick location than about format, so I presume they thought the 30 degree rotation would still be a sensible default

You could start looking through #2205 and 8d45dc4 for more info

Anyway, regardless of the design decision which was taken 10 years ago, it's probably not worth changing this now

@ptoche
Copy link
Author

ptoche commented Jan 14, 2022

The label's orientation feels like something distinct from the locator/formatter, maybe similar to the choice of font type and size. That's why I expected to be able to control it as a style, rather than within the call to plot. But yes, I'll just forget about this.

@ptoche ptoche closed this as completed Jan 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Triage Issue that has not been reviewed by a pandas team member Usage Question
Projects
None yet
Development

No branches or pull requests

2 participants