Skip to content

Instantly share code, notes, and snippets.

@aniruddha27
Created March 12, 2020 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aniruddha27/6c18b332a0873579340bc65f2002e200 to your computer and use it in GitHub Desktop.
Save aniruddha27/6c18b332a0873579340bc65f2002e200 to your computer and use it in GitHub Desktop.
#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