Skip to content

Conversation

@fangchenli
Copy link
Member

fangchenli and others added 2 commits November 4, 2025 20:14
…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 <noreply@anthropic.com>
@fangchenli fangchenli added the Visualization plotting label Nov 5, 2025
@fangchenli fangchenli requested a review from Copilot November 5, 2025 04:24
Copy link

Copilot AI left a 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.

@fangchenli fangchenli marked this pull request as draft November 5, 2025 05:01
…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 <noreply@anthropic.com>
@fangchenli fangchenli force-pushed the fix/issue-1918-bar-plot-dateformatter branch from 33fdcc1 to 54edf6b Compare November 5, 2025 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using pandas.TimeSeries_DateFormatter in bar plot?

1 participant