Complete the code to create a pie chart showing proportions of fruits.
import matplotlib.pyplot as plt sizes = [30, 45, 25] labels = ['Apples', 'Bananas', 'Cherries'] plt.pie(sizes, labels=[1]) plt.show()
The labels parameter adds names to each slice, showing what each proportion represents.
Complete the code to add percentages on each pie slice.
plt.pie(sizes, labels=labels, autopct=[1])
plt.show()The autopct parameter formats the percentage text on slices. '%.1f%%' shows one decimal place.
Fix the error in the code to correctly display the pie chart with a shadow.
plt.pie(sizes, labels=labels, autopct='%.1f%%', [1]=True) plt.show()
The correct parameter to add a shadow is shadow=True.
Fill both blanks to create a pie chart with exploded slices and a start angle.
explode = ([1], [2], 0) plt.pie(sizes, labels=labels, explode=explode, startangle=90) plt.show()
The first slice is exploded by 0.1, the second slice is not exploded (0).
Fill all three blanks to create a pie chart with colors, shadow, and percentage format.
colors = ['gold', 'yellowgreen', [1]] plt.pie(sizes, labels=labels, colors=colors, autopct=[2], [3]=True) plt.show()
The third color is 'lightcoral', percentages show no decimals with '%.0f%%', and shadow is enabled with shadow=True.