Interactive Scatter Plot

Learn to explore data by creating, moving, and analyzing points in real-time

Calculate

Try these examples:

Interactive Scatter Plot

Click, drag, and reshape data in real time. Every change recalculates statistics instantly.

How to Interact

  • Click the plot to add a point
  • Double-click a point to remove it
  • Drag any point to reposition it

{input:dataPoints}

Interactive Scatter Plot

P1P2P3P4P55102468XY

Live Statistics

StatisticValue
Points (nn)5
xˉ\bar{x}6
yˉ\bar{y}5.40
Correlation (rr)0.915
R2R^20.837

Correlation Strength

The Pearson correlation rr captures both direction and strength of a linear pattern:

  • r≈+1r \approx +1: strong positive trend (drag points into an upward line to see this)
  • r≈−1r \approx -1: strong negative trend
  • r≈0r \approx 0: no linear pattern

Try dragging a single point far from the cluster and watch rr = 0.915 shift.

Regression Line

The best-fit line minimizes squared residuals:

y^=0⋅x+0\hat{y} = {\cmv{computed}{slope}} \cdot x + {\cmv{computed}{intercept}}

Drag points to reshape the line. Adding an outlier far from the trend pulls both slope (0.600) and intercept (1.800) toward it.

Experiments

  1. Perfect line -- arrange points along a diagonal; rr approaches ±1\pm 1 and R2R^2 = 0.837 nears 11.
  2. Outlier effect -- load the "Positive Trend" preset, then drag one point far away. Watch rr = 0.915 drop.
  3. Cluster -- bunch all points together; with little spread the regression line wobbles and R2R^2 = 0.837 becomes unreliable.
  4. Presets -- load each preset above and compare the statistics.

Try it in Code

# Scatter plot with correlation and regression
import numpy as np
import matplotlib.pyplot as plt

x = np.array([2, 4, 6, 8, 10])
y = np.array([3, 5, 4, 7, 8])

r = np.corrcoef(x, y)[0, 1]
slope, intercept = np.polyfit(x, y, 1)
print(f"n = {len(x)}, Mean X = {x.mean():.2f}, Mean Y = {y.mean():.2f}")
print(f"Correlation r = {r:.3f}, R-squared = {r**2:.3f}")
print(f"y = {slope:.3f} * x + {intercept:.3f}")

plt.scatter(x, y)
plt.plot(x, slope * x + intercept, color="green")
plt.show()

Inputs

What to explore next

You might also like