R ggplot复杂网格额外布局
我想以以下方式布置三个图:R ggplot复杂网格额外布局,r,ggplot2,gridextra,R,Ggplot2,Gridextra,我想以以下方式布置三个图: [FirstPlot] [2nd] [3rd] 第一个图位于第二个和第三个图的顶部。第一个图的宽度是第二个和第三个图的两倍。现在让我们生成虚拟数据: library(gridExtra) library(grid) library(ggplot2) library(lattice) plot1 <- qplot(1, 1) plot2 <- qplot(1, 1) plot3 <- qplot(1, 1) lay <- rbind(c(1
[FirstPlot]
[2nd] [3rd]
第一个图位于第二个和第三个图的顶部。第一个图的宽度是第二个和第三个图的两倍。现在让我们生成虚拟数据:
library(gridExtra)
library(grid)
library(ggplot2)
library(lattice)
plot1 <- qplot(1, 1)
plot2 <- qplot(1, 1)
plot3 <- qplot(1, 1)
lay <- rbind(c(1,1),
c(2,3))
实际上不应该是这样,因为它不起作用。我得到以下错误。命令应该是什么来描绘这一切?我想我把grobs
部分搞错了
t:b:NA/NaN参数中出错
grobs参数需要list()而不是c():
grobsgrobs列表 grobs参数需要list()而不是c():
grobsgrobs列表
有一个简单的解决办法。使用
grobs=list(plot1、plot2、plot3)
有一个简单的修复方法。使用grobs=list(plot1、plot2、plot3)
我想提供一个解决方案,因为它是一个非常酷的包:
library(patchwork)
library(ggplot2)
plot1 <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
plot2 <- ggplot(diamonds, aes(cut, price)) + geom_boxplot()
plot3 <- ggplot(iris, aes(Sepal.Length, Sepal.Width)) + geom_point()
# One way of doing it
plot1 + (plot2 + plot3) + plot_layout(ncol = 1)
# Another, alternative solution
plot1 /
(plot2 | plot3)
库(拼凑)
图书馆(GG2)
plot1我想提供一个解决方案,因为它是一个非常酷的包:
library(patchwork)
library(ggplot2)
plot1 <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
plot2 <- ggplot(diamonds, aes(cut, price)) + geom_boxplot()
plot3 <- ggplot(iris, aes(Sepal.Length, Sepal.Width)) + geom_point()
# One way of doing it
plot1 + (plot2 + plot3) + plot_layout(ncol = 1)
# Another, alternative solution
plot1 /
(plot2 | plot3)
库(拼凑)
图书馆(GG2)
plot1我正在尝试,但是在sort.int(x,na.last=na.last,discreating=discreating,…)中得到了这个错误:'x'必须是原子的
--编辑--我打错了。没关系,它有用!谢谢。我正在尝试,但是在sort.int(x,na.last=na.last,discreating=discreating,…)“x”必须是原子的--EDIT--我输入了一个错误。没关系,它有用!谢谢。Bonustop=“top Label”
给你一个顶级标题。Bonustop=“top Label”
给你一个顶级标题
?grid.arrange
library(patchwork)
library(ggplot2)
plot1 <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
plot2 <- ggplot(diamonds, aes(cut, price)) + geom_boxplot()
plot3 <- ggplot(iris, aes(Sepal.Length, Sepal.Width)) + geom_point()
# One way of doing it
plot1 + (plot2 + plot3) + plot_layout(ncol = 1)
# Another, alternative solution
plot1 /
(plot2 | plot3)