Challenge - 5 Problems
Colormap and Colorbar Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this colormap and colorbar code?
Consider the following MATLAB code snippet:
What will the colorbar represent?
imagesc(peaks(10));
colormap(jet);
colorbar;
What will the colorbar represent?
MATLAB
imagesc(peaks(10));
colormap(jet);
colorbar;Attempts:
2 left
💡 Hint
Think about what the 'jet' colormap looks like and what colorbar does.
✗ Incorrect
The 'jet' colormap in MATLAB creates a smooth gradient from blue to red. The colorbar shows this gradient representing the range of data values in the image.
❓ Predict Output
intermediate2:00remaining
What is the effect of changing colormap to 'hot'?
Given this MATLAB code:
What color range will the colorbar display?
imagesc(magic(5));
colormap(hot);
colorbar;
What color range will the colorbar display?
MATLAB
imagesc(magic(5));
colormap(hot);
colorbar;Attempts:
2 left
💡 Hint
Recall the colors in the 'hot' colormap.
✗ Incorrect
The 'hot' colormap starts with black, then red, then yellow, and finally white for the highest values.
❓ Predict Output
advanced2:00remaining
What error occurs with this colormap command?
What error will this MATLAB code produce?
imagesc(rand(5));
colormap('unknownmap');
colorbar;
MATLAB
imagesc(rand(5)); colormap('unknownmap'); colorbar;
Attempts:
2 left
💡 Hint
Check if 'unknownmap' is a valid colormap name.
✗ Incorrect
MATLAB throws an error because 'unknownmap' is not a recognized colormap name or variable.
❓ Predict Output
advanced2:00remaining
What is the number of colors in this colormap?
Consider this MATLAB code:
How many distinct colors does the colormap have?
imagesc(peaks(20));
colormap(parula(10));
colorbar;
How many distinct colors does the colormap have?
MATLAB
imagesc(peaks(20)); colormap(parula(10)); colorbar;
Attempts:
2 left
💡 Hint
Look at the argument passed to parula.
✗ Incorrect
The number inside parula() specifies how many colors the colormap contains. Here it is 10.
🧠 Conceptual
expert3:00remaining
How does colorbar scale relate to data range?
In MATLAB, if you use:
and then change the color limits with:
What effect does this have on the colorbar and image colors?
imagesc(data);
colormap(jet);
colorbar;
and then change the color limits with:
caxis([10 20]);
What effect does this have on the colorbar and image colors?
MATLAB
imagesc(data); colormap(jet); colorbar; caxis([10 20]);
Attempts:
2 left
💡 Hint
Think about what caxis does to color scaling.
✗ Incorrect
The caxis function sets the data value limits for color mapping. Values below 10 map to the lowest color, above 20 to the highest color, and the colorbar reflects this range.