Chapter 38: R Scatter Plot

R Scatter Plot.

Scatter plots are the bread-and-butter of data exploration — they show relationships between two continuous variables, reveal patterns, clusters, outliers, correlations, trends… basically everything you need to “see” your data before doing any serious statistics.

We’ll go through this step by step like a real classroom session:

  • What it is and when to use it
  • Base R version (quick & dirty)
  • ggplot2 version (beautiful & modern)
  • customization tricks people actually use in 2026
  • common mistakes
  • your own mini practice

1. What is a Scatter Plot? (Simple & Honest Definition)

A scatter plot is a graph where:

  • Each observation (row) becomes a single point
  • One variable → x-axis
  • Another variable → y-axis

Goal: See if there is a relationship (linear, curved, none, clusters, outliers) between the two variables.

Classic real-life examples:

  • Height vs Weight
  • House size vs Price
  • Study hours vs Exam marks
  • Temperature vs Ice cream sales
  • Car weight vs Fuel efficiency

2. Base R Scatter Plot – Fastest Way (No Package Needed)

R

Add trend line (very common)

R

3. ggplot2 Scatter Plot – The Modern Professional Choice

This is what almost everyone uses when the plot needs to look good or go into a report/paper/presentation.

R

Color by category + smooth line + confidence band

R

Add size by another variable (very powerful)

R

4. Very Common Customizations People Actually Use

Want to do this… Base R way ggplot2 way (recommended)
Change point shape pch = 17 (triangle), 18 (diamond)… shape = 17, or aes(shape = Species)
Change point size cex = 1.5 size = 3.5 or aes(size = variable)
Add regression line abline(lm(y ~ x)) geom_smooth(method = “lm”)
Add smooth curve lines(lowess(x,y)) geom_smooth(method = “loess”)
Add confidence band Manual calculation geom_smooth(se = TRUE)
Color by category col = factor + legend() aes(color = category) → auto legend
Facet by group Manual multiple plots facet_wrap(~ Species) or facet_grid()
Add text labels text() geom_text() or ggrepel::geom_text_repel()

5. Quick Save Examples

R

6. Your Mini Practice Right Now (Copy → Run!)

R

Now try these experiments:

  • Change geom_smooth(method = “loess”)
  • Add facet_wrap(~ area)
  • Use shape = area instead of color
  • Add geom_text(aes(label = marks), vjust = -1)

Which version looks clearest to you?

Ready for more?

  • Want to add correlation coefficient or equation on the plot?
  • Learn marginal plots (scatter + histogram on sides)
  • Practice saving publication-ready scatter plots?
  • Or next plot type (boxplot, histogram, bar, heatmap)?

Just tell me — whiteboard is still clean! 📊✨🚀

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *