Learn R Programming

ggplot2bdc (version 0.3.2)

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

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

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

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

Run the code above in your browser using DataLab