Open
Description
This bug exists on the latest version of pandas and might be related to the bug reported in #51425.
df.plot
DataFrame with PeriodIndex
works well for frequency with n=1
, while fоr frequency that multiplies on n>1
we have a shift to the right.
Reproducible Examples:
if freq="7h"
from pandas import *
import numpy as np
idx = period_range("01/01/2000", freq='7h', periods=4)
df = DataFrame(
np.array([0, 1, 0, 1]),
index=idx,
columns=["A"],
)
df.plot()
print(df)
the plotting starts from 06:00

if freq="2h"
idx = period_range("01/01/2000", freq='2h', periods=4)
df = DataFrame(
np.array([0, 1, 0, 1]),
index=idx,
columns=["A"],
)
df.plot()
print(df)
we have a shift on +1 hour

But if freq="h"
idx = period_range("01/01/2000", freq='h', periods=4)
df = DataFrame(
np.array([0, 1, 0, 1]),
index=idx,
columns=["A"],
)
df.plot()
print(df)
the result looks okay:

Expected Behavior:
I think for both freq="7h"
and freq="2h"
we should start plotting from the point (00:00, 0.0)
as we do for freq="h"
In case DataFrame with DatetimeIndex
plotting works correct, e.g.
idx = date_range("01/01/2000", freq='7h', periods=4)
df = DataFrame(
np.array([0, 1, 0, 1]),
index=idx,
columns=["A"],
)
df.plot()
print(df)