ggdual_axis: Dual Y-axis for ggplot2

Description Usage Arguments Value References Examples

Description

lot dual y-axis for ggplot2 objects.

Usage

1
ggdual_axis(lhs, rhs, angle = 270)

Arguments

lhs

A plot whose y axis shall be on the left hand side.

rhs

A plot whose y axis shall be on the right hand side.

angle

Angle to rotate y-axis on right hand side.

Value

Returns an arrangeGrob with extra class ggdual_axis that plots by default. This allows it to be further combined with other grobs via grid.arrange.

References

http://stackoverflow.com/a/27608585/1000343 http://stackoverflow.com/a/25699817/1000343

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
p1 <- ggplot(mtcars, aes(mpg, disp)) +
    geom_line(colour = "blue") +
    theme_bw() +
    theme(plot.margin = grid::unit(c(.5, 1, .5, 0), "cm"))

p2 <- ggplot(mtcars, aes(mpg, drat)) +
    geom_line(colour = "red") +
    theme_bw() +
    theme(plot.margin = grid::unit(c(.5, 1, .5, 0), "cm"))

ggdual_axis(lhs = p1, rhs = p2)

trinker/plotflow documentation built on May 31, 2019, 9:42 p.m.