Complete the code to import the matplotlib pyplot module with the common alias.
import matplotlib.[1] as plt
The matplotlib.pyplot module is imported as plt to create plots easily.
Complete the code to create a list of values representing changes for the waterfall chart.
changes = [100, -30, 20, [1], -10]
The value 40 represents a positive change in the waterfall chart.
Fix the error in the code to correctly calculate the cumulative sums for the waterfall chart.
cumulative = [sum(changes[:[1]]) for i in range(len(changes))]
Using i+1 includes the current element in the sum for cumulative calculation.
Fill both blanks to create a waterfall chart using matplotlib with bars and labels.
plt.bar(range(len(cumulative)), cumulative, color=[1]) plt.xticks(range(len(labels)), [2]) plt.show()
The bars are colored blue, and the x-axis ticks use the labels list.
Fill all three blanks to add a title, label y-axis, and set grid lines on the chart.
plt.title([1]) plt.ylabel([2]) plt.grid([3])
The title is set to 'Waterfall Chart', y-axis label to 'Value Change', and grid lines are enabled with True.