gg_rescale: Rescale a ggplot2 plot so that axes follow a given ratio

Description Usage Arguments Value Examples

Description

gg_rescale rescales the given ggplot2 so that the axes follow the given ratio (horizontally). If a plot is not specified, the last plot displayed is used.

gg_rescale_golden rescales a ggplot2 plot so that axes follow golden ratio

gg_rescale_square rescales a ggplot2 plot so that its axes are square

Usage

1
2
3
4
5
gg_rescale(plot = last_plot(), ratio)

gg_rescale_golden(plot = last_plot(), orient = "h")

gg_rescale_square(plot = last_plot())

Arguments

plot

A ggplot2 plot object. By default, the last plot displayed is used.

ratio

The aspect ratio to use for the axes. This is independent of units used in the plot, so the size of the X axis will be ratio times the total size of the Y axis.

orient

Whether the golden ratio should be horizontal (h; default) or vertical (v)

Value

A modified ggplot2 plot

Examples

1
2
3
p <- ggplot(mtcars, aes(x = cyl, y = mpg)) +
    geom_point(shape = 1)
gg_rescale(ratio = 1.67)

briandconnelly/ggplot2bdc documentation built on May 13, 2019, 5:13 a.m.