0
0
Matplotlibdata~20 mins

Markers on data points in Matplotlib - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Marker Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of marker style in matplotlib scatter plot
What is the output of this code snippet that plots points with different markers?
Matplotlib
import matplotlib.pyplot as plt
x = [1, 2, 3]
y = [4, 5, 6]
plt.scatter(x, y, marker='^')
plt.show()
AA scatter plot with star markers at points (1,4), (2,5), (3,6)
BA scatter plot with circle markers at points (1,4), (2,5), (3,6)
CA scatter plot with square markers at points (1,4), (2,5), (3,6)
DA scatter plot with triangle-up markers at points (1,4), (2,5), (3,6)
Attempts:
2 left
💡 Hint
The marker parameter controls the shape of points in scatter plots.
data_output
intermediate
1:30remaining
Count of unique marker types in a plot
Given this code, how many unique marker types are used in the plot?
Matplotlib
import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [1, 4, 9, 16]
markers = ['o', 's', '^', 'o']
for xi, yi, m in zip(x, y, markers):
    plt.scatter(xi, yi, marker=m)
plt.show()
A3
B4
C2
D1
Attempts:
2 left
💡 Hint
Look at the list of markers and count distinct symbols.
🔧 Debug
advanced
1:30remaining
Identify the error in marker usage
What error does this code raise when run?
Matplotlib
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5, 6], marker='z')
plt.show()
ASyntaxError: invalid syntax
BValueError: Unrecognized marker style 'z'
CNo error, plots with default marker
DTypeError: marker must be a string
Attempts:
2 left
💡 Hint
Check if 'z' is a valid marker in matplotlib.
visualization
advanced
2:00remaining
Visual difference of marker sizes
Which option shows the plot with the largest marker size for the point at (2, 3)?
Matplotlib
import matplotlib.pyplot as plt
plt.scatter([1, 2, 3], [2, 3, 4], marker='o', s=50)
plt.scatter([2], [3], marker='o', s=200)
plt.show()
AThe point at (2, 3) is the largest circle marker on the plot
BAll points have the same marker size
CThe point at (3, 4) is the largest marker
DThe point at (1, 2) is the largest marker
Attempts:
2 left
💡 Hint
The 's' parameter controls marker size in scatter plots.
🚀 Application
expert
2:30remaining
Choosing markers for categorical data visualization
You want to plot three categories of data points with distinct markers for clarity. Which set of markers is best to ensure clear visual distinction?
A['o', 'o', 'o'] # all circles
B['.', ',', '_'] # point, pixel, horizontal line
C['o', 's', '^'] # circle, square, triangle-up
D['x', 'x', 'x'] # all crosses
Attempts:
2 left
💡 Hint
Use distinct shapes to differentiate categories clearly.