used to convert the x and y-axis of a ggplot to a log 10 scale that is more visually satisfying than the ggplot default.
Usage
gg_axis(
fo,
yaxis_scale = TRUE,
xaxis_scale = TRUE,
ylim_min = NULL,
ylim_max = NULL,
xlim_min = NULL,
xlim_max = NULL,
x_tick_label = TRUE,
y_tick_label = TRUE
)Arguments
- fo
ggplot figure object
- yaxis_scale
TRUEindicates that the y-axis should be log10 scaled- xaxis_scale
TRUEindicates that the x-axis should be log10 scaled- ylim_min
set to a number to define the lower bound of the y-axis
- ylim_max
set to a number to define the upper bound of the y-axis
- xlim_min
set to a number to define the lower bound of the x-axis
- xlim_max
set to a number to define the upper bound of the x-axis
- x_tick_label
TRUEto show x tick labels,FALSEto hide the x tick labels- y_tick_label
TRUEto show y tick labels,FALSEto hide the y tick labels
Examples
library("ggplot2")
#> Warning: package ‘ggplot2’ was built under R version 4.5.2
df = data.frame(x = seq(0.01,10,.01),
y = seq(0.01,10,.01)^2)
p = ggplot(df, aes(x=x, y=y)) + geom_line()
# pretty up the axes
p = prepare_figure(fo=p, purpose="print")
#> Warning: The `size` argument of `element_rect()` is deprecated as of ggplot2 3.4.0.
#> ℹ Please use the `linewidth` argument instead.
#> ℹ The deprecated feature was likely used in the ubiquity package.
#> Please report the issue at <https://github.com/john-harrold/ubiquity/issues>.
# pretty log10 y-axis
p_logy = gg_log10_yaxis(fo=p)
# pretty log10 x-axis
p_logx = gg_log10_xaxis(fo=p)
# pretty log10 yx-axis
p_logxy = gg_axis(fo=p)
