liveBook · Manning

Geom_point() function

As explained in Statistics Slam Dunk

The ggplot2 geom_point() function adds point or marker layers to a plot according to mapped data aesthetics.

geom_point() adds point layers to ggplot2 graphics, producing correlation plots—also called scatterplots—from two mapped numeric variables. Use size = 3 to draw points three times their default size. section 4.5.3 section 14.4.1

A typical correlation plot combines geom_point() with:

  • ggplot() mappings that place one variable on the x-axis and another on the y-axis. section 4.5.3 section 14.4.1
  • geom_smooth(method = lm, se = FALSE) to add a linear regression line without its default confidence interval. section 4.5.3 section 14.4.1
  • Labels and scales that identify the variables, correlation coefficient, and axis formatting. section 4.5.3
p7 <- ggplot(free_agents, aes(x = annual_salary, y = win_shares)) + 
  geom_point(size = 3) +
  labs(title = "Annual Salaries vs. Win Shares",
       subtitle = "correlation coefficient = 0.76",
       x = "Annual Salaries", 
       y = "Win Shares") + 
  geom_smooth(method = lm, se = FALSE) +
  scale_x_continuous(label = scales::comma) +
  theme(plot.title = element_text(face = "bold"))
print(p7)

Run this complete NBA example to plot annual salaries against win shares with enlarged points, labels, a regression line, and formatted salaries. section 4.5.3

How Statistics Slam Dunk covers it

How deep it goes
Defines point plotting, sizing, mappings, and common layering but does not explain geom internals.
Examples
Uses NBA salaries versus win shares and points allowed or scored versus wins.
What it assumes
Assumes a data source and two numeric variables mapped through ggplot().
What you can do after
Apply it via ggplot2 to build scatterplots and compare relationships between NBA statistics.
How it connects
Connects ggplot2 aesthetics, scatterplots, correlation coefficients, linear regression, and geom_smooth().

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Slam Dunk. The section links point to the parts of the book it draws on.