Complete the code to create a pie chart with one slice exploded.
import matplotlib.pyplot as plt sizes = [30, 20, 50] explode = [[1], 0, 0] plt.pie(sizes, explode=explode) plt.show()
The explode list controls how far each slice is offset from the center. Using 0.1 for the first slice explodes it slightly.
Complete the code to explode the second slice in the pie chart.
import matplotlib.pyplot as plt sizes = [10, 40, 50] explode = [0, [1], 0] plt.pie(sizes, explode=explode) plt.show()
Setting the second value in explode to 0.2 offsets the second slice slightly from the center.
Fix the error in the explode list to correctly explode the third slice.
import matplotlib.pyplot as plt sizes = [25, 25, 50] explode = [0, 0, [1]] plt.pie(sizes, explode=explode) plt.show()
The explode value must be a float, not a string or boolean. 0.3 correctly explodes the third slice.
Fill both blanks to explode the first and third slices in the pie chart.
import matplotlib.pyplot as plt sizes = [15, 35, 50] explode = [[1], 0, [2]] plt.pie(sizes, explode=explode) plt.show()
Using 0.15 and 0.25 explodes the first and third slices slightly and moderately, respectively.
Fill all three blanks to explode the first and third slices and set labels for the pie chart.
import matplotlib.pyplot as plt sizes = [20, 30, 50] labels = [[1], 'B', [2]] explode = [[3], 0, 0] plt.pie(sizes, labels=labels, explode=explode) plt.show()
Labels 'A' and 'C' are set for the first and third slices. Exploding the first slice by 0.1 offsets it slightly.