Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created May 14, 2020 23:58
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 codecademydev/cf83b562c9f1ab1513e5e25e8673c895 to your computer and use it in GitHub Desktop.
Save codecademydev/cf83b562c9f1ab1513e5e25e8673c895 to your computer and use it in GitHub Desktop.
Codecademy export
import codecademylib
from matplotlib import pyplot as plt
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
visits_per_month = [9695, 7909, 10831, 12942, 12495, 16794, 14161, 12762, 12777, 12439, 10309, 8724]
# numbers of limes of different species sold each month
key_limes_per_month = [92.0, 109.0, 124.0, 70.0, 101.0, 79.0, 106.0, 101.0, 103.0, 90.0, 102.0, 106.0]
persian_limes_per_month = [67.0, 51.0, 57.0, 54.0, 83.0, 90.0, 52.0, 63.0, 51.0, 44.0, 64.0, 78.0]
blood_limes_per_month = [75.0, 75.0, 76.0, 71.0, 74.0, 77.0, 69.0, 80.0, 63.0, 69.0, 73.0, 82.0]
# create your figure here
plt.figure(figsize = (12, 8))
ax1 = plt.subplot(1, 2, 1)
x_values = range(len(months))
plt.plot(x_values, visits_per_month, marker = 'o')
plt.xlabel('Months')
plt.ylabel('Visits Per Month')
ax1.set_xticks(x_values)
ax1.set_xticklabels(months)
plt.title('Visitors Per Month')
plt.subplots_adjust(hspace = 0.55)
ax2 = plt.subplot(1, 2, 2)
plt.plot(x_values, key_limes_per_month, color = 'green', marker = 's')
plt.plot(x_values, persian_limes_per_month, color = 'blue', marker = '*')
plt.xlabel('Months')
plt.ylabel('Number of Limes Sold')
plt.plot(x_values, blood_limes_per_month, color = 'brown', marker = 'o')
plt.legend(['key limes', 'persian limes', 'blood limes'])
ax2.set_xticks(x_values)
ax2.set_xticklabels(months)
plt.title('Limes Sold Per Month')
plt.subplots_adjust(hspace = 0.55)
plt.savefig('Customers and Their Sales Habits.png')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment