[R-sig-Geo] R-help: How to draw the same legend (one legend) for the multiple spatial figures?

duan.scut.cn at gmail.com duan.scut.cn at gmail.com
Fri Aug 4 16:06:32 CEST 2017


Dear all, I have ploted several spatial figures, but every one have legend and some of them are different. But I want to plot only one legend for these figures? So could you help me how to make it? I have the following lines for each figure:
  # draw figure
 ##  Open a new default device.
#get( getOption( "device" ) )()
##  Set up plotting in two rows and three columns, plotting along rows first.
 #par( mfrow = c( 3, 3 ) )
my.palette <- brewer.pal(n = 7, name = "OrRd") # set the color styles
##  The first plot is located in row 1, column 1:
a<-spplot(nc1,sp.layout = list("sp.lines", as(lev, "SpatialLines")),main="All",col.regions=my.palette, cuts = 6, col = "transparent",scales=list(draw = TRUE),par.settings=list(fontsize=list(text=17)))
#plot( rnorm( n = 10 ), col = "red", main = "plot 1", cex.lab = 1.1 )
##  The second plot is located in row 1, column 2:
b<-spplot(nc2,sp.layout = list("sp.lines", as(lev, "SpatialLines")),main="CC",col.regions=my.palette, cuts = 6, col = "transparent",scales=list(draw = TRUE),par.settings=list(fontsize=list(text=17)))
##  The third plot is located in row 1, column 3:
c<-spplot(nc3,sp.layout = list("sp.lines", as(lev, "SpatialLines")),main="GF",col.regions=my.palette, cuts = 6, col = "transparent",scales=list(draw = TRUE),par.settings=list(fontsize=list(text=17)))
##  The fourth plot is located in row 2, column 1:
d<-spplot(nc4,sp.layout = list("sp.lines", as(lev, "SpatialLines")),main="HA",col.regions=my.palette, cuts = 6, col = "transparent",scales=list(draw = TRUE),par.settings=list(fontsize=list(text=17)))
##  The fifth plot is located in row 2, column 2:
e<-spplot(nc5,sp.layout = list("sp.lines", as(lev, "SpatialLines")),main="MI",col.regions=my.palette, cuts = 6, col = "transparent",scales=list(draw = TRUE),par.settings=list(fontsize=list(text=17)))
##  The sixth plot is located in row 2, column 3:
f<-spplot(nc6,sp.layout = list("sp.lines", as(lev, "SpatialLines")),main="MP",col.regions=my.palette, cuts = 6, col = "transparent",scales=list(draw = TRUE),par.settings=list(fontsize=list(text=17)))
##  The seventh plot is located in row 3, column 1:
g<-spplot(nc7,sp.layout = list("sp.lines", as(china, "SpatialLines")),main="MR",col.regions=my.palette, cuts = 6, col = "transparent",scales=list(draw = TRUE),par.settings=list(fontsize=list(text=17)))

       Of them, nc1-nc7 are the raster data.
     Thanks a lot!

Wei
      



duan.scut.cn at gmail.com

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list