log10_breaks: Create nice breaks for graphs of log-transformed data

View source: R/log10_breaks.R

log10_breaksR Documentation

Create nice breaks for graphs of log-transformed data

Description

log10_breaks creates a vector of numbers fairly evenly spaced on a log 10 scale with 10 points. (They're more evenly spaced if "min" and "max" span 1 order of magnitude.) The decimals aren't necessarily pretty, though, so you may want to set "prettify" to TRUE if they're ugly.

Usage

log10_breaks(min, max, prettify = FALSE)

Arguments

min

minimum value to use for breaks

max

maximum value to use for breaks

Value

a numeric vector

Examples

data("ConcTime")
ggplot(ConcTime, aes(x = Time, y = Conc, color = ID)) +
   geom_line() +
   scale_y_log10(breaks = log10_breaks(min = min(ConcTime$Conc[ConcTime$Conc > 0]),
                                       max = max(ConcTime$Conc)))

ggplot(ConcTime, aes(x = Time, y = Conc, color = ID)) +
   geom_line() +
   scale_y_log10(breaks = log10_breaks(min = min(ConcTime$Conc[ConcTime$Conc > 0]),
                                       max = max(ConcTime$Conc),
                                       prettify = TRUE))



shirewoman2/Consultancy documentation built on Feb. 18, 2025, 10 p.m.