Pandas equivalent of binary sensor plots

Hi all, I wish to recreate in pandas/matplotlib the binary sensor plots in HA:

I believe the closest available is barh, but my current effort is not satisfactory as I do not have a linear time scale on the horizontal axis, and I want the time that a sensors was on/off displayed in the width.
Any advice gratefully received!
Cheers

1 Like

How’s this?

fig, ax = plt.subplots(1, 1, figsize=(10, 2))
ax.fill_between(times.index, y1=0, y2=1, facecolor = 'royalblue', label = 'off')
ax.fill_between(times.index, where = (times['value'] == 1), y1=0, y2=1, facecolor = 'red' , label = 'on')
plt.xlabel('Date'); plt.yticks([]); plt.title('Binary Sensor Plot')
plt.legend();
a=fig.gca()
a.set_frame_on(False)
1 Like