expand0: Convenience functions to remove space between plot and axes

View source: R/theme_helpers.R

expand0R Documentation

Convenience functions to remove space between plot and axes

Description

expand0() and expand1() are a convenience functions that call expansion(mult = c(0,0)) and expansion(mult = c(0,0.1)), respectively, to remove space between the plot and the axes. See expansion() for more information on setting the space between the plotted data and the axes.

Usage

expand0()

expand1()

Examples

library(ggplot2)

p <- ggplot(faithfuld, aes(waiting, eruptions, fill = density)) +
    geom_raster() +
    scale_fill_distiller(palette = "YlGn") +
    scale_x_continuous(expand = expand0()) +
    scale_y_continuous(expand = expand0())

df <- data.frame(
    x = factor(c("IL6R", "IL8R", "IL6R-Ab", "IL8R-Ab", "IL6R-Ab-IL8R"),
          levels = c("IL6R", "IL8R", "IL6R-Ab", "IL8R-Ab", "IL6R-Ab-IL8R")),
    y = c(0.45, 0.78, 0.61, 0.31, 0.72))
p <- ggplot(df, aes(x, y, fill = x)) +
    geom_col() +
    scale_y_continuous(expand = expand1())

christyray/crthemes documentation built on April 14, 2023, 11:18 p.m.