liveBook · Manning

Line plot

As explained in Statistics Slam Dunk

A line chart represents values or trends across ordered positions by connecting plotted points with line segments.

A line plot represents values or trends across ordered positions by connecting plotted points with line segments. In R, ggplot2 combines geom_line() with geom_point() when both the trend and the individual observations matter. section 13.4 section 16.3

Build a useful line plot by:

  • Preparing one row per ordered position, such as season, trial, streak length, or independent trial count. section 13.4 section 16.4.2
  • Mapping the ordered variable to x and the measured value to y, then setting group = 1 when the data contain one series. section 16.3 section 16.4.2
  • Adding geom_line() for the connected trend and geom_point() for visible observations; adjust size, color, labels, axes, and themes for readability. section 13.4 section 16.3
  • Interpreting the shape rather than merely reading values: a curve can reveal increasing values at a decreasing rate, irregular variation, or a trend that does not match a reference pattern. section 16.3 section 16.4.2

Plot a probability curve

After calculating Laplace probabilities, map independent_trials to x and laplace to y: ggplot(df, aes(x = independent_trials, y = laplace, group = 1)) + geom_line(color = "purple", size = 1.5) + geom_point(size = 3, color = "purple"). The resulting plot shows probability increasing at a decreasing rate without reaching 100%. section 16.3

ggplot(ws_gini_summary, aes(x = Year, y = gc, group = 1)) + 
 geom_line(aes(y = gc), color = "black", size = .5) + 
 geom_point(size = 5, color = "seagreen3") +
 geom_text(aes(label = gc),
           nudge_x = 0.01, nudge_y = 0.01,
           check_overlap = TRUE, size = 2.5) +
 labs(title = "Gini Coefficient for Win Shares", 
      subtitle = "1991-2017",
      x = "Season", 
      y = "Gini Coeffiicient",
      caption = "includes a maximum top 14 win shares for each team") +
 ylim(0.42, 0.60) +
 theme(plot.title = element_text(hjust = 0.5, face = "bold")) +
 theme(plot.subtitle = element_text(hjust = 0.5)) +
 theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
 annotate("rect", xmin = "1991", xmax = "2009", 
          ymin = 0.42, ymax = 0.60, alpha = 0.1, fill = "orange") +
 annotate("rect", xmin = "2010", xmax = "2017", 
          ymin = 0.42, ymax = 0.60, alpha = 0.1, fill = "blue")

Explore a labeled year-over-year Gini line plot with enlarged points, rotated season labels, adjusted axis limits, and shaded periods. section 13.4

How Statistics Slam Dunk covers it

How deep it goes
Explains data preparation, aesthetics, geoms, axis controls, labels, themes, and visual interpretation without deriving plotting internals.
Examples
Uses NBA win-share inequality, Laplace probability, and Julius Randle free-throw percentages following consecutive makes.
What it assumes
Assumes basic R data frames and calculated variables while demonstrating grouped summaries and ggplot2 mappings.
What you can do after
Apply it via ggplot2 to build, customize, and interpret ordered trends with connected points.
How it connects
Connects line plots with scatterplots, trendlines, probability curves, Gini coefficients, and free-throw streak analysis.

Also explained in

Compare how 6 books explain line plot →

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.