0
0
Data Analysis Pythondata~10 mins

Scatter plots in Data Analysis Python - Interactive Code Practice

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

Complete the code to create a scatter plot using matplotlib.

Data Analysis Python
import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [10, 20, 25, 30]
plt.[1](x, y)
plt.show()
Drag options to blanks, or click blank then click option'
Ascatter
Bplot
Cbar
Dhist
Attempts:
3 left
💡 Hint
Common Mistakes
Using plt.plot() which creates a line plot instead of scatter plot.
Using plt.bar() which creates bar charts, not scatter plots.
2fill in blank
medium

Complete the code to add labels to the x and y axes in the scatter plot.

Data Analysis Python
import matplotlib.pyplot as plt
x = [5, 7, 8, 7, 2]
y = [99, 86, 87, 88, 100]
plt.scatter(x, y)
plt.xlabel([1])
plt.ylabel('Scores')
plt.show()
Drag options to blanks, or click blank then click option'
A'Weight'
B'Height'
C'Age'
D'Temperature'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to put the label text inside quotes.
Using the wrong label that does not match the data.
3fill in blank
hard

Fix the error in the code to correctly plot a scatter plot with red points.

Data Analysis Python
import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [10, 20, 25, 30]
plt.scatter(x, y, color=[1])
plt.show()
Drag options to blanks, or click blank then click option'
Ared
B'r'
Cr
D'red'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing color without quotes causing a NameError.
Using full color name without quotes.
4fill in blank
hard

Fill both blanks to create a scatter plot with blue points and size 100.

Data Analysis Python
import matplotlib.pyplot as plt
x = [2, 4, 6, 8]
y = [5, 15, 25, 35]
plt.scatter(x, y, color=[1], s=[2])
plt.show()
Drag options to blanks, or click blank then click option'
A'blue'
B50
C100
D'green'
Attempts:
3 left
💡 Hint
Common Mistakes
Using color without quotes.
Setting size too small to notice.
5fill in blank
hard

Fill all three blanks to create a scatter plot with green points, size 80, and alpha transparency 0.5.

Data Analysis Python
import matplotlib.pyplot as plt
x = [1, 3, 5, 7]
y = [2, 4, 6, 8]
plt.scatter(x, y, color=[1], s=[2], alpha=[3])
plt.show()
Drag options to blanks, or click blank then click option'
A'green'
B80
C0.5
D'yellow'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing color without quotes.
Using alpha values outside 0 to 1 range.
Setting size too small or too large.