0
0
Matplotlibdata~10 mins

Stacked area chart in Matplotlib - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the correct plotting library for creating a stacked area chart.

Matplotlib
import [1] as plt
Drag options to blanks, or click blank then click option'
Apandas
Bmatplotlib.pyplot
Cseaborn
Dnumpy
Attempts:
3 left
💡 Hint
Common Mistakes
Importing 'numpy' or 'pandas' instead of 'matplotlib.pyplot'.
Using 'seaborn' which is a different plotting library.
2fill in blank
medium

Complete the code to define the x-axis values for the stacked area chart.

Matplotlib
x = [1](1, 6)
Drag options to blanks, or click blank then click option'
Arange
Bnp.array
Clist
Dpd.Series
Attempts:
3 left
💡 Hint
Common Mistakes
Using list without specifying the sequence.
Using np.array without importing numpy.
3fill in blank
hard

Fix the error in the code to correctly plot the stacked area chart using plt.stackplot.

Matplotlib
plt.stackplot(x, y1, y2, [1]=labels)
plt.show()
Drag options to blanks, or click blank then click option'
Alabels
Blegend
Ctitle
Dlabel
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'label' instead of 'labels' causes the legend not to show.
Using 'legend' as a parameter causes an error.
4fill in blank
hard

Fill both blanks to create a stacked area chart with a legend and axis labels.

Matplotlib
plt.stackplot(x, y1, y2, [1]=labels)
plt.[2]('X axis')
plt.show()
Drag options to blanks, or click blank then click option'
Alabels
Bxlabel
Cylabel
Dlegend
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'label' instead of 'labels' in stackplot.
Using 'ylabel' instead of 'xlabel' for the x-axis label.
5fill in blank
hard

Fill all three blanks to create a stacked area chart with labels, y-axis label, and a legend.

Matplotlib
plt.stackplot(x, y1, y2, [1]=labels)
plt.[2]('Y axis')
plt.[3]()
Drag options to blanks, or click blank then click option'
Alabels
Bylabel
Clegend
Dtitle
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to call legend() to display the legend.
Using 'label' instead of 'labels' in stackplot.