I am looking for a clever way to produce a plot styled like this rather childish example:
with source data like this:
days = ['Monday','Tuesday','Wednesday','Thursday','Friday']
Feature Values observed on
0 1 [5.5, 14.3, 12.0, 11.8] [Tuesday, Wednesday, Thursday, Friday]
1 2 [6.1, 14.6, 12.7] [Monday, Tuesday, Wednesday]
2 3 [15.2, 13.3] [Tuesday, Friday]
3 4 [14.9, 14.3, 17.0] [Monday, Thursday, Friday]
4 5 [13.0, 13.1, 13.5, 10.3] [Monday, Tuesday, Thursday, Friday]
5 6 [12.5, 7.0] [Wednesday, Friday]
In other words, for each line of this dataframe, I want to plot/connect the values for the "days" on which they were acquired. (Please note the days are here just to illustrate my problem, using datetime is not a solution.) But I got lost in indexing.
This is how I prepared the figure (i.e. having vertical black lines for each day)
for count, log in enumerate(days):
plt.plot(np.ones(len(allvalues))*count,np.array(allvalues),'k',linestyle='-',linewidth=1.)
plt.xticks(np.arange(0,5,1),['M','T','W','T','F'])
and this works, I get my vertical lines and the labels. (later I may want to plot other datasets instead of those vertical lines, but for now, the vertical lines are more illustrative) But now, how can I plot the values for each day?
for index, group in observations.iterrows():
whichdays= group['observed on']
values = group['Values']
for d in whichdays:
plt.plot(days[np.where(days==d)],values)
but this produces TypeError: list indices must be integers, not tuple