patchwork

Combine and merge legends in ggplot2 with patchwork

和自甴很熟 提交于 2021-02-09 19:34:25
问题 I would like to combine two or more plots merging their legends. For example, I can create some data and two scenarios as follows. # packages library(ggplot2) library(patchwork) # first plot set.seed(07042020) x <- runif(50) y <- runif(50) data1 <- data.frame(x = x, y = y, z = runif(50, 0, 2)) p1 <- ggplot(data1) + geom_point(aes(x, y, col = z)) p1 data2 <- data.frame(x = x, y = y, z = runif(50, -1, 1)) p2 <- ggplot(data2) + geom_point(aes(x, y, col = z)) p2 The following code is what I tried

Combine and merge legends in ggplot2 with patchwork

牧云@^-^@ 提交于 2021-02-09 19:31:39
问题 I would like to combine two or more plots merging their legends. For example, I can create some data and two scenarios as follows. # packages library(ggplot2) library(patchwork) # first plot set.seed(07042020) x <- runif(50) y <- runif(50) data1 <- data.frame(x = x, y = y, z = runif(50, 0, 2)) p1 <- ggplot(data1) + geom_point(aes(x, y, col = z)) p1 data2 <- data.frame(x = x, y = y, z = runif(50, -1, 1)) p2 <- ggplot(data2) + geom_point(aes(x, y, col = z)) p2 The following code is what I tried

Combine and merge legends in ggplot2 with patchwork

谁说胖子不能爱 提交于 2021-02-09 19:30:00
问题 I would like to combine two or more plots merging their legends. For example, I can create some data and two scenarios as follows. # packages library(ggplot2) library(patchwork) # first plot set.seed(07042020) x <- runif(50) y <- runif(50) data1 <- data.frame(x = x, y = y, z = runif(50, 0, 2)) p1 <- ggplot(data1) + geom_point(aes(x, y, col = z)) p1 data2 <- data.frame(x = x, y = y, z = runif(50, -1, 1)) p2 <- ggplot(data2) + geom_point(aes(x, y, col = z)) p2 The following code is what I tried

Combine and merge legends in ggplot2 with patchwork

瘦欲@ 提交于 2021-02-09 19:28:48
问题 I would like to combine two or more plots merging their legends. For example, I can create some data and two scenarios as follows. # packages library(ggplot2) library(patchwork) # first plot set.seed(07042020) x <- runif(50) y <- runif(50) data1 <- data.frame(x = x, y = y, z = runif(50, 0, 2)) p1 <- ggplot(data1) + geom_point(aes(x, y, col = z)) p1 data2 <- data.frame(x = x, y = y, z = runif(50, -1, 1)) p2 <- ggplot(data2) + geom_point(aes(x, y, col = z)) p2 The following code is what I tried

Combine and merge legends in ggplot2 with patchwork

醉酒当歌 提交于 2021-02-09 19:25:18
问题 I would like to combine two or more plots merging their legends. For example, I can create some data and two scenarios as follows. # packages library(ggplot2) library(patchwork) # first plot set.seed(07042020) x <- runif(50) y <- runif(50) data1 <- data.frame(x = x, y = y, z = runif(50, 0, 2)) p1 <- ggplot(data1) + geom_point(aes(x, y, col = z)) p1 data2 <- data.frame(x = x, y = y, z = runif(50, -1, 1)) p2 <- ggplot(data2) + geom_point(aes(x, y, col = z)) p2 The following code is what I tried