Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#dictionary for meals per food item
item_count = {}
for i in range(table.index.nunique()):
item_count[table.index[i]] = table.num_orders[i]/df_meal[df_meal['category']==table.index[i]].shape[0]
#bar plot
plt.bar([x for x in item_count.keys()],[x for x in item_count.values()],color='orange')
#adjust xticks
plt.xticks(rotation=70)
#label x-axis
plt.xlabel('Food item')
#label y-axis
plt.ylabel('No. of meals')
#label the plot
plt.title('Meals per food item')
#save plot
plt.savefig('C:\\Users\\Dell\\Desktop\\AV Plotting images\\matplotlib_plotting_7.png',dpi=300,bbox_inches='tight')
#display plot
plt.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment