combine_plots {agroclim}R Documentation

Combine plots

Description

This function combines two plots build with ggplot2 and use both legends.

Usage

combine_plots(plot1, plot2)

Arguments

plot1

First plot to draw.

plot2

Second plot that will be drawed over the first.

Value

A gtable object.

Examples


library(ggplot2)
df <- mtcars[, c("disp", "qsec", "cyl")]
plot1 <- ggplot(df, aes(x=cyl, y=qsec)) +
         geom_point() + theme_bw()
plot2 <- ggplot(df, aes(x=disp, y=qsec, color = factor(cyl))) +
         geom_line() + theme_void() + theme(legend.position = c(0.9, 0.8))
cb <- combine_plots(plot1, plot2)
plot(cb)


[Package agroclim version 0.1.0 Index]