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.
