Scatter Plot 🌌
Visualizing Relationships
Scatter plots are the best way to visualize the relationship (correlation) between two numerical variables.
✨ Creating a Scatter Plot
python
import matplotlib.pyplot as plt
x = [5,7,8,7,2,17,2,9,4,11,12,9,6]
y = [99,86,87,88,111,86,103,87,94,78,77,85,86]
plt.scatter(x, y)
plt.show()📈 Correlation
What are we looking for?
- Positive Correlation: As x increases, y increases.
- Negative Correlation: As x increases, y decreases.
- No Correlation: No visible pattern.
💡 Large Datasets
Scatter plots are excellent for large datasets (e.g., 1000+ points) to see clusters and density.
python
import numpy as np
import matplotlib.pyplot as plt
x = np.random.normal(5.0, 1.0, 1000)
y = np.random.normal(10.0, 2.0, 1000)
plt.scatter(x, y)
plt.show()