Код: Выделить всё
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
fig = plt.figure()
gs = gridspec.GridSpec(4, 1, height_ratios=[1, 1, 1, 1])
ax1 = fig.add_subplot(gs[0])
ax2 = fig.add_subplot(gs[1])
ax3 = fig.add_subplot(gs[2])
ax4 = fig.add_subplot(gs[3])
ax1.set_title("Month ends first")
pd.Series([0, 2, 0], pd.DatetimeIndex(["2025-11-30", "2025-12-31", "2026-01-31"])).plot(ax=ax1, c="b")
pd.Series([0, 1, 0], pd.DatetimeIndex(["2025-11-30", "2025-12-15", "2026-01-31"])).plot(ax=ax1, c="r")
ax2.set_title("Middle of month first")
pd.Series([0, 1, 0], pd.DatetimeIndex(["2025-11-30", "2025-12-15", "2026-01-31"])).plot(ax=ax2, c="r")
pd.Series([0, 2, 0], pd.DatetimeIndex(["2025-11-30", "2025-12-31", "2026-01-31"])).plot(ax=ax2, c="b")
ax3.set_title("Not end of month first")
pd.Series([0, 2, 0], pd.DatetimeIndex(["2025-11-28", "2025-12-31", "2026-01-31"])).plot(ax=ax3, c="b")
pd.Series([0, 1, 0], pd.DatetimeIndex(["2025-11-30", "2025-12-15", "2026-01-31"])).plot(ax=ax3, c="r")
ax4.set_title("Not end of month first fence post")
pd.Series([0, 2, 0], pd.DatetimeIndex(["2025-11-27", "2025-12-31", "2026-01-31"])).plot(ax=ax4, c="b")
pd.Series([0, 1, 0], pd.DatetimeIndex(["2025-11-30", "2025-12-15", "2026-01-31"])).plot(ax=ax4, c="r")
plt.show()

Подробнее здесь: https://stackoverflow.com/questions/798 ... lign-dates