Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
207 views
in Technique[技术] by (71.8m points)

How to plot 10 maps as one figure in R?

I am using this code to plot 10 maps as one figure in r? i want aplabeltical orders (a) (b) etc below the maps and years 2009-2019 above the figure. I have given Greens as result colour of ndvi in R. Its not prominant. Which colour can i use to make it more visible?

library(raster)
library(rgdal)
library(rasterVis)
library(lattice)
library(RColorBrewer)

r1 <- raster("E:/GB extent(2009-2019)/rasterstack.tif", band=1)

r2 <- raster("E:/GB extent(2009-2019)/rasterstack.tif", band=2)
r3 <- raster("E:/GB extent(2009-2019)/rasterstack.tif", band=3)
r4 <- raster("E:/GB extent(2009-2019)/rasterstack.tif", band=4)
r5 <- raster("E:/GB extent(2009-2019)/rasterstack.tif", band=5)
r6 <- raster("E:/GB extent(2009-2019)/rasterstack.tif", band=6)
r7 <- raster("E:/GB extent(2009-2019)/rasterstack.tif", band=7)
r8 <- raster("E:/GB extent(2009-2019)/rasterstack.tif", band=8)
r9 <- raster("E:/GB extent(2009-2019)/rasterstack.tif", band=9)
r10 <- raster("E:/GB extent(2009-2019)/rasterstack.tif", band=10)

boudary <- readOGR(dsn= "E:/Shapefile/New folder/GB_Bondary.shp", layer =  "GB_Bondary")





raster_stack <- stack(r1,r2,r3,r4,r5,r6,r7,r8,r9,r10)

#levelplot(raster_stack, layout=c(5,2)


colr <- colorRampPalette((brewer.pal(3, 'Greens')))

levelplot(raster_stack,
          layout=c(5,2),
          margin=FALSE, 
          #main=list("title",col="Black",fontface='bold'),
          colorkey=list(
            space='right',                   
            labels=list(at=c(0.5,0.6,0.7,0.8,0.9,1.0), font=5,fontface='bold'),
            axis.line=list(col='black'),
            width=0.75
          ),    
          par.settings=list(
            strip.border=list(col='transparent'),
            strip.background=list(col='transparent'),
            axis.line=list(col='transparent')
          ),
          scales=list(draw=FALSE),
          col.regions=colr,                   
          at=seq(0.5,1.0, len=101),
          names.attr=(c('2009','2010','2011',
                        '2013','2014','2015','2016'
                        ,'2017','2018','2019')),font=list(face="bold"),cex=.4)+
  layer(sp.polygons(boudary, lwd=0.5))

###########################################################################

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...