Challenge - 5 Problems
Scatter Plot Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of Basic Scatter Plot Command
What will be the output of the following MATLAB code snippet?
MATLAB
x = 1:5; y = [2 4 6 8 10]; scatter(x, y, 'filled')
Attempts:
2 left
💡 Hint
The 'filled' option fills the markers with the default color.
✗ Incorrect
The scatter function plots points as circles by default. The 'filled' option fills these circles with the default blue color. No line is drawn connecting points.
❓ Predict Output
intermediate2:00remaining
Effect of Marker Size in Scatter Plot
What is the effect of the marker size argument in this MATLAB scatter plot code?
MATLAB
x = 1:3; y = [3 6 9]; scatter(x, y, 100, 'r')
Attempts:
2 left
💡 Hint
The third argument in scatter is the marker size in points squared.
✗ Incorrect
The number 100 sets the marker size to be large. The color 'r' sets the marker color to red.
🔧 Debug
advanced2:00remaining
Identify the Error in Scatter Plot Code
What error will this MATLAB code produce when run?
MATLAB
x = 1:4; y = [2 4 6]; scatter(x, y)
Attempts:
2 left
💡 Hint
Check the length of x and y vectors.
✗ Incorrect
The scatter function requires x and y to have the same number of elements. Here x has 4 elements but y has 3, causing an error.
🧠 Conceptual
advanced2:00remaining
Understanding Color Mapping in Scatter Plots
Given the code below, what does the vector 'c' control in the scatter plot?
MATLAB
x = 1:5; y = [5 4 3 2 1]; c = [10 20 30 40 50]; scatter(x, y, 100, c, 'filled') colorbar
Attempts:
2 left
💡 Hint
The fourth argument in scatter can be a vector for color data.
✗ Incorrect
The vector 'c' assigns a color value to each point. The colorbar shows the mapping from values to colors.
🚀 Application
expert3:00remaining
Creating a Scatter Plot with Variable Marker Sizes and Colors
Which code snippet correctly creates a scatter plot with x and y coordinates, marker sizes proportional to y values, and colors mapped to x values?
Attempts:
2 left
💡 Hint
The third argument is marker size, the fourth is color data.
✗ Incorrect
The scatter function syntax is scatter(x, y, size, color, 'filled'). Option B correctly assigns marker sizes to y and colors to x.