-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
ENH: use TimeSeries_DateFormatter in bar plot #62992
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
base: main
Are you sure you want to change the base?
ENH: use TimeSeries_DateFormatter in bar plot #62992
Conversation
…s (GH#1918) Bar plots now use TimeSeries_DateFormatter for datetime and period indices, matching the formatting behavior of line plots. This provides consistent date formatting across different plot types. Changes: - Modified BarPlot._post_plot_logic() to detect time series indices - Convert DatetimeIndex to PeriodIndex for consistent formatting - Apply format_dateaxis() for proper date label formatting - Added test to verify bar plots use TimeSeries_DateFormatter - Updated secondary legend tests to use 'D' frequency instead of deprecated 'B' 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
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.
Pull Request Overview
This PR enhances bar plots with datetime/period indices to use the TimeSeries_DateFormatter, matching the formatting behavior of line plots. This addresses issue #1918 where bar plots previously converted datetime indices to strings, losing the dynamic date formatting capabilities.
Key changes:
- Modified
BarPlot._post_plot_logic()to detect time series indices and apply date formatting - Updated test cases to use "D" (daily) frequency instead of "B" (business day) frequency
- Added a new test to verify the correct formatter is applied to bar plots with datetime indices
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pandas/plotting/_matplotlib/core.py | Added time series detection and date formatter logic to BarPlot._post_plot_logic(), importing decorate_axes function |
| pandas/tests/plotting/test_datetimelike.py | Changed test frequencies from "B" to "D" and added new test for bar plot date formatter |
| doc/source/whatsnew/v3.0.0.rst | Added changelog entry documenting the new behavior |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…s (GH#1918) Bar plots now use TimeSeries_DateFormatter for datetime and period indices, matching the behavior of line plots. This provides consistent date formatting across different plot types instead of converting indices to string labels. Also update test_memory_leak to use 'D' (daily) frequency instead of deprecated 'B' (business day) frequency to avoid FutureWarning. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
33fdcc1 to
54edf6b
Compare
doc/source/whatsnew/vX.X.X.rstfile if fixing a bug or adding a new feature.