import matplotlib.pyplot as plt
sandwich_list = [
'Lobster roll',
'Chicken caesar',
'Bang bang chicken',
'Ham and cheese',
'Tuna and cucumber',
'Egg',
]
boston_price_list = [9.99, 7.99, 7.49, 7, 6.29, 4.99]
london_price_list = [7.5, 5, 4.4, 5, 3.75, 2.25]
fig, ax = plt.subplots(figsize=(5,6))
plt.grid()
plt.title("Selected Pret A Manger sandwiches (US\$ price)\nAug 2019\n\n")
plt.plot(london_price_list, sandwich_list, 's', color='C0', label='London')
plt.plot(boston_price_list, sandwich_list, 's', color='C3', label='Boston')
plt.hlines(sandwich_list, london_price_list, boston_price_list)
# show every other tick:
lims = ax.get_xlim()
lims = round(lims[0],0), round(lims[1],0)
ax.xaxis.set_ticks(np.arange(lims[0], lims[1]+2, 2))
ax.tick_params(axis="y", labelsize=12)
ax.tick_params(bottom=False, labelbottom=False,
top=True, labeltop=True,
left=True, labelleft=True
)
for side in ['top','right','bottom']:
ax.spines[side].set_visible(False)
plt.legend(loc=(.2,1.08), ncol=2, frameon=False, fontsize=11)
plt.show()