Challenge - 5 Problems
Bubble Chart Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of Bubble Chart Size Scaling
What will be the size of the bubbles in the plot generated by the following code snippet?
Matplotlib
import matplotlib.pyplot as plt x = [1, 2, 3] y = [4, 5, 6] sizes = [10, 20, 30] plt.scatter(x, y, s=sizes) plt.show() print(sizes)
Attempts:
2 left
💡 Hint
The 's' parameter in plt.scatter controls the area of each bubble, not the radius.
✗ Incorrect
The sizes list is passed directly to the 's' parameter, which sets the area of each bubble in points squared. The printed sizes list remains unchanged.
❓ data_output
intermediate2:00remaining
Number of Bubbles Displayed
Given the following data and code, how many bubbles will appear in the bubble chart?
Matplotlib
import matplotlib.pyplot as plt x = [1, 2, 3, 4] y = [10, 20, 30, 40] sizes = [15, 25, 35] plt.scatter(x, y, s=sizes) plt.show()
Attempts:
2 left
💡 Hint
The lengths of x, y, and sizes must match for plt.scatter.
✗ Incorrect
The sizes list has fewer elements than x and y, causing a ValueError due to mismatched array lengths.
❓ visualization
advanced2:30remaining
Interpreting Bubble Chart Colors and Sizes
Consider this code that creates a bubble chart with color and size representing different data aspects. What does the color represent in the resulting plot?
Matplotlib
import matplotlib.pyplot as plt import numpy as np x = np.array([5, 15, 25, 35, 45]) y = np.array([10, 20, 30, 40, 50]) sizes = np.array([100, 200, 300, 400, 500]) colors = np.array([1, 2, 3, 4, 5]) plt.scatter(x, y, s=sizes, c=colors, cmap='viridis') plt.colorbar() plt.show()
Attempts:
2 left
💡 Hint
The 'c' parameter controls color mapping in plt.scatter.
✗ Incorrect
The 'c' parameter is set to the 'colors' array, so bubble colors correspond to these values mapped through the 'viridis' colormap.
🔧 Debug
advanced2:00remaining
Identify the Error in Bubble Chart Code
What error will this code produce when run?
Matplotlib
import matplotlib.pyplot as plt x = [1, 2, 3] y = [4, 5] sizes = [10, 20, 30] plt.scatter(x, y, s=sizes) plt.show()
Attempts:
2 left
💡 Hint
Check if x and y have the same number of elements.
✗ Incorrect
x has 3 elements but y has 2, causing ValueError due to mismatched input sizes for scatter plot.
🚀 Application
expert3:00remaining
Choosing Bubble Sizes for Visual Clarity
You have data points with values ranging from 1 to 1000. You want to create a bubble chart where bubble sizes reflect these values but remain visually clear and not too large. Which approach is best to set the bubble sizes?
Attempts:
2 left
💡 Hint
Bubble area grows with the size parameter, so large raw values can cause huge bubbles.
✗ Incorrect
Applying square root to values before sizing keeps bubble areas proportional to data but prevents very large bubbles, improving visual clarity.