0
0
Matplotlibdata~10 mins

Why categorical visualization matters in Matplotlib - Test Your Understanding

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

Complete the code to import the matplotlib plotting library.

Matplotlib
import [1] as plt
Drag options to blanks, or click blank then click option'
Aseaborn
Bmatplotlib.pyplot
Cpandas
Dnumpy
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the whole matplotlib instead of pyplot
Using seaborn or pandas instead of matplotlib.pyplot
Forgetting the 'as plt' alias
2fill in blank
medium

Complete the code to create a bar chart for categories and their counts.

Matplotlib
categories = ['A', 'B', 'C']
counts = [10, 15, 7]
plt.[1](categories, counts)
plt.show()
Drag options to blanks, or click blank then click option'
Ascatter
Bhist
Cplot
Dbar
Attempts:
3 left
💡 Hint
Common Mistakes
Using plot or scatter which are better for continuous data
Using hist which is for numerical distributions
3fill in blank
hard

Fix the error in the code to label the x-axis with category names.

Matplotlib
plt.bar([1, 2, 3], [5, 7, 3])
plt.xticks([1, 2, 3], [1])
plt.show()
Drag options to blanks, or click blank then click option'
A['A', 'B', 'C']
B['5', '7', '3']
C[5, 7, 3]
D[1, 2, 3]
Attempts:
3 left
💡 Hint
Common Mistakes
Using counts or positions as labels instead of category names
Passing numbers instead of strings for labels
4fill in blank
hard

Fill both blanks to create a horizontal bar chart with labels and title.

Matplotlib
plt.[1](counts, categories)
plt.xlabel('[2]')
plt.title('Category Counts')
plt.show()
Drag options to blanks, or click blank then click option'
Abarh
Bbar
CCounts
DCategories
Attempts:
3 left
💡 Hint
Common Mistakes
Using bar instead of barh for horizontal bars
Labeling the x-axis as 'Categories' instead of 'Counts'
5fill in blank
hard

Fill all three blanks to create a pie chart with labels and percentage display.

Matplotlib
plt.[1](counts, labels=[2], autopct='[3]')
plt.title('Category Distribution')
plt.show()
Drag options to blanks, or click blank then click option'
Apie
Bcategories
C%1.1f%%
Dbar
Attempts:
3 left
💡 Hint
Common Mistakes
Using bar instead of pie for pie charts
Not passing labels or passing wrong labels
Incorrect format string for autopct