main title in densityplot into grid.arrange raster stack data

时间:2015-09-01 22:15:00

标签: r plot r-raster raster-graphics

I am using the function densityplot() and grid.arrange(), this is the example:

library(rasterVis)
library(gridExtra)
library(raster)

f <- system.file("external/test.grd", package="raster")
r <- raster(f)
data<-stack(r,r*2,r/3,r+100,r,r*2,r*2,r/3,r+100,r,r-10,r)
names(data) <- month.abb
a<- densityplot(data[[1:3]],main="title 1")
b<- densityplot(data[[4:6]],main="title 2")
c<- densityplot(data[[7:9]],main="title 3")
d<- densityplot(data[[10:12]],main="title 4")

grid.arrange(a,b,c,d,ncol=2,top="main title ")

Using this code my output is:

output 1

No show "title 1", "title 2" .... and the output using with my data is:

output 2

equal does not display the main title of the densityplot and the label ("Jan" "Feb" "Mar" "Apr" ....)

It is possible that can guide me please.

thank you!!

0 个答案:

没有答案