liveBook · Manning

Scale_x_continuous() function

As explained in Statistics Slam Dunk

The ggplot2 scale_x_continuous() function configures a continuous x-axis scale, including its limits, breaks, labels, and transformations.

scale_x_continuous() formats the continuous x-axis in ggplot2 charts, making large numeric values, currency, or proportions easier to read. section 10.4.2 section 4.5.1

Common applications include:

  • Format payroll labels as dollar amounts abbreviated to millions, such as $20 M, with label_dollar() and cut_short_scale(). section 10.4.2
  • Add commas to large salary values with the scales package’s comma formatter. section 4.5.1
  • Display Lorenz-curve axes as percentages with the percent formatter. section 12.6

Format an NBA payroll axis

After mapping payroll to x, add scale_x_continuous(labels = label_dollar(scale_cut = cut_short_scale())). Rotate the resulting labels with theme(axis.text.x = element_text(angle = 45, hjust = 1)) when space is tight.

How Statistics Slam Dunk covers it

How deep it goes
Demonstrates label formatting with scales functions but does not detail limits, breaks, transformations, or scale internals.
Examples
Uses NBA payroll dollars, free-agent salaries, and Lorenz-curve proportions as concrete axis-labeling examples.
What it assumes
Assumes basic ggplot2 plot construction and familiarity with mapping a numeric variable to x.
What you can do after
Apply it via ggplot2 and scales formatters to produce readable continuous x-axis labels.
How it connects
Connects continuous scales with ggplot2, the scales package, density plots, and Lorenz curves.

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.