October 2018
Beginner to intermediate
676 pages
18h 30m
English
The following code block plots a pie chart of the genre of movies released in a year:
labels = ['SciFi', 'Drama', 'Thriller', 'Comedy', 'Action', 'Romance']sizes = [5, 15, 10, 20, 40, 10] # Add upto 100%
explode = (0, 0, 0, 0, 0.1, 0) # only "explode" the 5th slice (i.e.'Action')
plt.pie(sizes, labels=labels, explode=explode, autopct='%1.1f%%', shadow=True, startangle=90)
plt.axis('equal')
plt.show()
Read now
Unlock full access