我用filled.contour函数创建了一些图。然后我想绘制两个彼此相邻的情节。因此我使用了grid.arrange函数。 这是我的代码:grid.arrange with filled.contour in R Studio
install.packages("gridExtra")
install.packages("lattice")
install.packages("grid")
library(lattice)
library(gridExtra)
library(grid)
# Fake data
x <- c(1:10)
y <- c(1:10)
z<-matrix(data=c(1:100), nrow=10, ncol=10, byrow = FALSE)
p1<-filled.contour(x,y,z, color = terrain.colors, asp = 1) # simple
# Lay out both plots
grid.arrange(p1,p1, ncol=2)
但我得到的是:
错误为Glist(名单(wrapvp =列表(x = 0.5,Y = 0.5,宽度= 1,高度 = 1,:只有在 “为Glist” 允许
这就是为什么我想这个 'grobs':
install.packages("gridExtra")
install.packages("lattice")
install.packages("grid")
library(lattice)
library(gridExtra)
library(grid)
# Fake data (taken from the fill.contour help examples)
x <- c(1:10)
y <- c(1:10)
z<-matrix(data=c(1:100), nrow=10, ncol=10, byrow = FALSE)
p1<-filled.contour(x,y,z, color = terrain.colors, asp = 1) # simple
p1<-grob(p1)
is.grob(p1)
# Lay out both plots
grid.arrange(p1,p1, ncol=2)
但是这也行不通。你能帮我吗?
'filled.contour'是一个基本的图形函数,而不是一个'lattice'函数,并且不会产生一个grob或一个可以变成grob的对象(虽然也许可以把它变成通过'gridBase'包中的函数进入grob)。如果输入'p1 <-filled.contour(x,y,z,color = terrain.colors,asp = 1)',然后键入'p1',则输出为NULL。 'lattice'具有可能是你需要的'contour','contourplot'和'levelplot'功能。 – eipi10
也见http://stackoverflow.com/questions/27929452/r-return-corrplot-as-object./#27948707 – user2957945
我与contourplot和levelplot的问题是事实,他们需要与filled.contour不同的输入。 – rsl93