Skip to content

Closed: fork was outdated #56611

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
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v2.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,7 @@ Plotting
^^^^^^^^
- Bug in :meth:`DataFrame.plot.box` with ``vert=False`` and a Matplotlib ``Axes`` created with ``sharey=True`` (:issue:`54941`)
- Bug in :meth:`DataFrame.plot.scatter` discarding string columns (:issue:`56142`)
- Bug in :meth:`DataFrame.plot` where bar and line plots are not aligned on the x-axis (:issue:`56611`)
- Bug in :meth:`Series.plot` when reusing an ``ax`` object failing to raise when a ``how`` keyword is passed (:issue:`55953`)

Groupby/resample/rolling
Expand Down
16 changes: 15 additions & 1 deletion pandas/plotting/_matplotlib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1805,6 +1805,15 @@ def _kind(self) -> Literal["bar", "barh"]:
def orientation(self) -> PlottingOrientation:
return "vertical"

@final
def _is_ts_plot(self) -> bool:
# this is slightly deceptive
return not self.x_compat and self.use_index and self._use_dynamic_x()

@final
def _use_dynamic_x(self) -> bool:
return use_dynamic_x(self._get_ax(0), self.data)

def __init__(
self,
data,
Expand All @@ -1823,7 +1832,6 @@ def __init__(
self.bar_width = width
self._align = align
self._position = position
self.tick_pos = np.arange(len(data))

if is_list_like(bottom):
bottom = np.array(bottom)
Expand All @@ -1836,6 +1844,12 @@ def __init__(

MPLPlot.__init__(self, data, **kwargs)

self.tick_pos = (
np.array(self._get_xticks(), dtype=int)
if (self._is_series and not self._is_ts_plot)
else np.arange(len(data))
)

@cache_readonly
def ax_pos(self) -> np.ndarray:
return self.tick_pos - self.tickoffset
Expand Down