-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Make xticks from _quarterly_finder() line up better #47602
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
Conversation
When I plot a series of quarterly data that spans more than 11 years, my vertical grid lines get placed a year before where they should, i.e., one year before a year that is divisible by the default annual spacing. Changing one line in the _quarterly_finder() function, from +1 to +1970, fixes this for me. Can anyone please confirm the issue and that this fixes it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, could you add a test for this?
Hey, I'm not too familiar with the project's test infrastructure, so I apologize if this isn't too convenient, but here's a standalone test that works for me.
|
Please review https://pandas.pydata.org/pandas-docs/stable/development/contributing_codebase.html#test-driven-development-code-writing for adding unit tests. We cannot accept bug fixes without a unit test |
Hello @elidourado! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2022-07-15 17:28:32 UTC |
# valid ranges are from 11.25 to 584.5 years, limited at the bottom by | ||
# if statements in the _quarterly_finder() function and at the top end | ||
# by the Timestamp format | ||
def test_quarterly_finder(year_span): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Could you put this test in
pandas/tests/plotting/test_converter.py
? - Can this test be simplified at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the test over to that file and also simplified the initial test data generation a bit. I'm not sure how to simplify the test further without losing coverage or sacrificing clarity. Open to guidance, however.
Let me know what else I can do to get this committed! |
check_minor_years = minor_quarters.year % min_anndef == 0 | ||
check_major_quarters = major_quarters.quarter == 1 | ||
check_minor_quarters = minor_quarters.quarter == 1 | ||
assert ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you just use 4 individual asserts? it will make it easier to diagnose if one of the asserts fails in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the code checks are failing below with the red x. Please review the logs to see what formatting checks may have failed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fairly good. Could you add a note in the whatsnew/1.5.0.rst
about the bug fix? (Visualization section)
Done. I had to make a new visualization section in the 1.5.0 what's new file. There is an existing plotting section. Would it be better to consolidate and move the note there? |
Thanks for sticking with this @elidourado |
When I plot a series of quarterly data that spans more than 11 years, my vertical grid lines get placed a year before where they should, i.e., one year before a year that is divisible by the default annual spacing. Changing one line in the _quarterly_finder() function, from +1 to +1970, fixes this for me. Can anyone please confirm the issue and that this fixes it?