Learn R Programming

plotflow (version 0.2.1)

ggdual_axis: Dual Y-axis for ggplot2

Description

lot dual y-axis for ggplot2 objects.

Usage

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

Run this code
# NOT RUN {
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)
# }

Run the code above in your browser using DataLab