Scatter Plot
ggplot2: geom_point() · Package: ggplot2 · Variables: 2 numerical
WHAT IS A SCATTER PLOT?
A scatter plot (also called a scatter diagram or XY plot) places individual data points on two axes to reveal the relationship between two continuous variables. It is the go-to chart for answering "is there a correlation between X and Y?" Scatter plots reveal patterns like positive/negative correlations, clusters, and outliers that are invisible in summary statistics. Add a trend line with geom_smooth() to highlight the overall pattern. Color or shape aesthetics can encode a third variable (categorical grouping). Scatter plots require at least 10-15 data points to show meaningful patterns.
BEST FOR
- · Correlation analysis
- · Identifying clusters
- · Detecting outliers
- · Bivariate exploration
AVOID WHEN
- · Categorical data on either axis
- · Fewer than 10 data points
- · Time-series trend
R + GGPLOT2 CODE EXAMPLE
ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point(color = "#ff6a00", size = 2) + labs(title = "Weight vs MPG", x = "Weight (1000 lbs)", y = "MPG")
Run this code now
Paste the code above into RChat and see the scatter plot rendered instantly in your browser.