In [1]:
from IPython.display import HTML
HTML('<img src="./before.png" width=1200>')


Out[1]:

In [6]:
import numpy as np
import matplotlib.pyplot as plt

np.random.seed(0)

x = np.asarray([3, 6, 9, 12])
fund = np.asarray([73.8 + 1.91, 13.23, 10.69, 0.37])
recom = np.asarray([6, 11, 1, 9]) / 27 * 100
fs = 16
shift=0.42

plt.figure()

colors = ['blue', 'orange']
ax = plt.gca()
rects1 = ax.bar(x-shift, fund, color=colors[0], label='Federal Subsidies for Food Production')
rects2 = ax.bar(x+shift, recom, color=colors[1], label='Federal Nutrition Recommendations')
ax.legend(prop={'size': fs+2})
plt.xticks(x, ['Protein (Meat, Dairy, Nuts, ...)', 'Grains', 'Sugar, Oil, Salt', 'Vegetables, Fruits'],
           fontsize=fs)
plt.title('Why Does a Salad Cost More Than a Big Mac?', fontsize=fs+8)

# https://matplotlib.org/examples/api/barchart_demo.html
def autolabel(rects):
    """
    Attach a text label above each bar displaying its height
    """
    for rect in rects:
        height = rect.get_height()
        ax.text(rect.get_x() + rect.get_width()/2., height+0.5,
                '%0.2f%%' % height,
                ha='center', va='bottom', fontsize=fs)

autolabel(rects1)
autolabel(rects2)

plt.rcParams["figure.figsize"] = (20, 15)
plt.show()



In [3]:
HTML('<img src="./Big Mac.png" width=1200>')


Out[3]:

In [4]:
HTML('<img src="./Mac Breakdown.png" width=1200>')


Out[4]: