I have a dataframe that looks like this:
runtime name grade
2021-05-28 Jimmy 50.34
2021-05-28 John 51.02
2021-05-28 Sherry 51.28
2021-05-28 Angela 45.99
2021-05-28 Mary 48.64
...
2021-08-23 Nathan 46.65
2021-08-23 Angela 50.64
2021-08-23 Sherry 46.77
2021-08-23 John 48.55
2021-08-23 Albert 48.89
I would like to create a subplot with df['grade']
for each unique df['name']
and a shared x-axis: runtime
This is what I have so far.
n = len(pd.unique(dfp['name']))
fig, axs = plt.subplots(nrows=n, figsize=(7, 5), sharex=True)
for ax, column, label in zip(axs,['grade'],['name']):
dfp.plot(x='runtime', xlabel="Date", y=column, ylabel=label, kind='line', marker='o',linewidth=2,legend=False, ax=ax)
This creates a figure with n
plots, but it plots all of the points on the top row.