Bird
0
0
Raspberry Piprogramming~10 mins

Matplotlib for data visualization in Raspberry Pi - 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 Matplotlib plotting library.

Raspberry Pi
import matplotlib[1] as plt
Drag options to blanks, or click blank then click option'
A.graph
B.plot
C.pyplot
D.chart
Attempts:
3 left
💡 Hint
Common Mistakes
Using .plot or .chart instead of .pyplot
Forgetting to import pyplot module
2fill in blank
medium

Complete the code to create a simple line plot of y values.

Raspberry Pi
plt.[1]([1, 2, 3, 4], [10, 20, 25, 30])
plt.show()
Drag options to blanks, or click blank then click option'
Ascatter
Bhist
Cbar
Dplot
Attempts:
3 left
💡 Hint
Common Mistakes
Using scatter or bar instead of plot for line graphs
Not calling plt.show() to display the plot
3fill in blank
hard

Fix the error in the code to add a title to the plot.

Raspberry Pi
plt.plot([1, 2, 3], [4, 5, 6])
plt.[1]('My Plot')
plt.show()
Drag options to blanks, or click blank then click option'
Atitle
Blabel
Cxlabel
Dlegend
Attempts:
3 left
💡 Hint
Common Mistakes
Using label or xlabel instead of title
Forgetting to call plt.show()
4fill in blank
hard

Fill both blanks to create a bar chart with labels and display it.

Raspberry Pi
plt.[1](['A', 'B', 'C'], [5, 7, 3])
plt.[2]('Categories')
plt.show()
Drag options to blanks, or click blank then click option'
Abar
Bxlabel
Cylabel
Dplot
Attempts:
3 left
💡 Hint
Common Mistakes
Using plot() instead of bar() for bar charts
Using ylabel() instead of xlabel() for x-axis label
5fill in blank
hard

Fill all three blanks to create a scatter plot with axis labels and a title.

Raspberry Pi
plt.[1]([1, 2, 3, 4], [10, 20, 25, 30])
plt.[2]('X Axis')
plt.[3]('My Scatter Plot')
plt.show()
Drag options to blanks, or click blank then click option'
Aplot
Bxlabel
Ctitle
Dscatter
Attempts:
3 left
💡 Hint
Common Mistakes
Using plot() instead of scatter()
Mixing up xlabel() and title()