I am trying to create a graph of blood pressures from a blood pressure recording device. I have extracted all of the data from the device and stored the timestamp of each reading as a DateTime:
import pandas as pd
import matplotlib.pyplot as plt
dataframe["DateTime"] = pd.to_datetime(df[["Year", "Month", "Day", "Hour", "Minute"]]).dt.strftime('%d/%m/%y %H:%M')
x = dataframe.DateTime
a1 = pd.Series(dataframe["BP1 Sys"])
a2 = pd.Series(dataframe["BP2 Dia"])
a3 = pd.Series(dataframe["MAP"])
plt.title(title)
plt.plot(x, a1, marker="^")
plt.plot(x, a2, marker="v")
plt.axhline(y=130)
plt.axhline(y=60)
plt.plot(x, a3, linestyle="dotted", color='green')
plt.bar(x=x, height=a1 - a2, bottom=a2, width=0.05, alpha=.2)
plt.fill_between(x, a1, a2, color='blue', alpha=.1)
plt.gcf().autofmt_xdate()
plt.show()
However, when I create this graph it seems to treat each timestamp as a unique entry (like a bar chart with string labels) rather than creating a continuous axis. This means that every reading looks like it was taken an equal amount of time apart (when come may have a few minutes between and others a few hours). It also means that it creates an X axis mark for each point, rather than putting an appropriate amount of markers in:
Any Idea what I am doing wrong?