ggfortify icon indicating copy to clipboard operation
ggfortify copied to clipboard

Merging legends

Open sinhrks opened this issue 8 years ago • 0 comments

Looks possible but can't work well with current ggmultiplot as legend must be considered as plot (grob). Needs separated class to dot this, or logic to merge the same legends when output.

p <- autoplot(lm(Petal.Width ~ Petal.Length, data = iris), colour = 'Species', data = iris)

grob <- ggplotGrob(p@plots[[1]])
leg <- grob$grobs[[which(grob$layout$name == "guide-box")]]

plots <- lapply(p@plots, function(x) x + theme(legend.position = 'none'))
plots[[5]] <- leg

layout_matrix = rbind(c(1, 2, 5), c(3, 4, 5))
do.call(grid.arrange, c(plots, list(ncol = 3, layout_matrix = layout_matrix))

rplot

sinhrks avatar Jan 11 '16 03:01 sinhrks