I have a dataset that looks like this: dataset With this code:
df_lists = df[['FC-Final [l/100km]']].unstack().apply(pd.Series)
df_lists.plot.bar(rot=30, cmap=plt.cm.jet, fontsize=8, width=0.7, figsize=(8,4),
title='Fuel Consumption per route', ylabel='FC-Final [l/100km]')
I manage to generate this graph mybarchart
I am trying to add the values from the 'Route' column as xticks instead of the current ones but I get this error:
ValueError: Missing category information for StrCategoryConverter; this might be caused by unintendedly mixing categorical and numeric data
My questions:
- How can I add the values from 'Route' column as xticks?
- Is it possible to add a secondary y-axis so that each bar level corresponds to both the 'FC-Final [l/100km]'(main y-axis) AND the 'distance [km]'(secondary y-axis)?
- Can I also display the values from 'time [min]' column right on top o each corresponding bar?
I face trouble because as seen in the dataset, some routes have 2 different fuel consumptions and time and some others have 3 or even 1...