Challenge - 5 Problems
Alpha Transparency Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the effect of alpha in this scatter plot?
Consider this code that plots two overlapping scatter plots with different alpha values. What will be the visual effect of setting alpha=0.3 for the second plot?
Matplotlib
import matplotlib.pyplot as plt x = [1, 2, 3, 4, 5] y1 = [5, 4, 3, 2, 1] y2 = y1 plt.scatter(x, y1, color='blue', label='Set 1') plt.scatter(x, y2, color='red', alpha=0.3, label='Set 2') plt.legend() plt.show()
Attempts:
2 left
💡 Hint
Alpha controls transparency from 0 (invisible) to 1 (fully visible).
✗ Incorrect
Alpha=0.3 means the red points are 30% opaque and 70% transparent, so you can see the blue points underneath where they overlap.
❓ data_output
intermediate1:30remaining
How many points are visible after applying alpha transparency?
Given two overlapping scatter plots each with 5 points, where the second plot uses alpha=0.5, how many points will be visible in the final plot?
Matplotlib
import matplotlib.pyplot as plt x = [1, 2, 3, 4, 5] y1 = [5, 4, 3, 2, 1] y2 = y1 plt.scatter(x, y1, color='green', label='Set 1') plt.scatter(x, y2, color='orange', alpha=0.5, label='Set 2') plt.legend() plt.show() visible_points = len(x) * 2
Attempts:
2 left
💡 Hint
Alpha affects transparency, not the number of points drawn.
✗ Incorrect
Both sets have 5 points each, so total 10 points are drawn and visible, though some overlap with transparency.
🔧 Debug
advanced2:30remaining
Why does this plot not show transparency?
This code tries to plot two overlapping histograms with alpha=0.5, but the transparency effect is not visible. What is the cause?
Matplotlib
import matplotlib.pyplot as plt import numpy as np data1 = np.random.normal(0, 1, 1000) data2 = np.random.normal(0, 1, 1000) plt.hist([data1, data2], bins=30, color=['blue', 'red'], alpha=0.5) plt.show()
Attempts:
2 left
💡 Hint
Check how matplotlib handles overlapping histograms by default.
✗ Incorrect
By default, plt.hist stacks histograms, so the second histogram covers the first, hiding transparency effects.
❓ visualization
advanced2:00remaining
Which plot shows correct alpha blending for overlapping areas?
You have two overlapping scatter plots with alpha=0.4 and alpha=0.6 respectively. Which plot correctly shows the combined color intensity in overlapping areas?
Matplotlib
import matplotlib.pyplot as plt import numpy as np x = np.random.rand(50) y = np.random.rand(50) plt.scatter(x, y, color='purple', alpha=0.4, label='Set 1') plt.scatter(x, y, color='yellow', alpha=0.6, label='Set 2') plt.legend() plt.show()
Attempts:
2 left
💡 Hint
Alpha blending mixes colors based on transparency levels.
✗ Incorrect
The overlapping points blend purple and yellow colors weighted by their alpha values, producing a mixed color with medium brightness.
🧠 Conceptual
expert1:30remaining
Why use alpha transparency in data visualization?
Which of the following is the best reason to use alpha transparency when plotting overlapping data points?
Attempts:
2 left
💡 Hint
Think about how transparency helps when many points overlap.
✗ Incorrect
Alpha transparency helps reveal areas with many overlapping points by making them darker or more intense, showing density.