Two Lines Chart (Matplotlib) - CLASS 6

Published: 01 January 1970
on channel: Fala tu, Nerd!
16
6

import matplotlib.pyplot as plt

#Class months: May, June, July, August and September

labels = [1, 2, 3, 4, 5]
months = [1, 2, 3, 4, 5]
men = [38, 41, 50, 56, 52]
women = [32, 36, 56, 60, 56]

fig, ax = plt.subplots()

ax.plot(months, men, 'r-o', label = 'Men')
for i in range(len(months)):
ax.text(months[i]-0.2, men[i]+0.8, '{}' .format(men[i]))

ax.plot(months, women, 'b--s', label = 'Women')
for i in range(len(months)):
ax.text(months[i]-0.2, women[i]+0.8, '{}' .format(women[i]))

ax.set_title('Summer Classes')
ax.set_xlabel('Months')
ax.set_ylabel('Amount of People')
ax.legend()

x = ['May', 'Jun', 'Jul', 'Aug', 'Sep']
plt.xticks([1, 2, 3, 4, 5], x)

plt.xlim(0.5, 5.5)
plt.ylim(30, 65)

plt.show()


On this page of the site you can watch the video online Two Lines Chart (Matplotlib) - CLASS 6 with a duration of hours minute second in good quality, which was uploaded by the user Fala tu, Nerd! 01 January 1970, share the link with friends and acquaintances, this video has already been watched 16 times on youtube and it was liked by 6 viewers. Enjoy your viewing!