I have data that looks like this
ID value_y date_x end_cutoff
1 75 2020-7-1 2021-01-17
1 73 2020-7-2 2021-01-17
1 74 2020-7-1 2021-06-05
1 71 2020-7-2 2021-06-05
2 111 2020-7-1 2021-01-17
2 112 2020-7-2 2021-01-17
2 113 2020-7-1 2021-06-05
2 115 2020-7-2 2021-06-05
And I want to plot the following data such that the following are met:
- Each ID has 1 graph
- Each graph has n lines plotted (2 in this example; 1 for each end_cutoff)
So, ideally in this example I would have two separate plots both with two lines.
Currently here is the code I have but it plots them all but on the same plot instead of a new plot for each ID.
grouped = df_fit.groupby(['ID','end_cutoff'])
fig, ax = plt.subplots()
for (ID, end_cutoff), df_fit in grouped:
ax.plot(df_fit['date_x'], df_fit['value_y'], label=ID+' '+str(end_cutoff.date()))
plt.show()
