Ah! That alpha parameter is a transparency setting in your scatter plot. Let me break it down:
Code context
housing = strat_train_set.copy()
housing.plot(kind="scatter", x="longitude", y="latitude", alpha=0.1)
plt.show()
-
kind="scatter" → Makes a scatter plot
-
x="longitude", y="latitude" → Plots longitude on the x-axis, latitude on the y-axis
-
alpha=0.1 → Sets transparency of the points
What alpha does
-
Range: 0 (fully transparent) → 1 (fully opaque)
-
Purpose:
-
When you have lots of overlapping points, fully opaque points can hide density patterns.
-
A low alpha (like 0.1) makes points semi-transparent.
-
You can see areas with more overlapping points as darker regions.
-
Think of it like looking through a foggy layer of dots—more dots in the same spot = darker, clearer density visualization.
Example:
-
alpha=1 → Every dot is solid → overlapping dots hide each other
-
alpha=0.1 → Dots are see-through → you can see clusters more clearly
In your case, since housing likely has thousands of locations, alpha=0.1 helps reveal population density patterns across longitude/latitude.
0 Comments