1

I have a rasterbrick comprising of six layers

class : RasterBrick dimensions : 47, 89, 4183, 6 (nrow, ncol, ncell, nlayers) resolution : 0.5, 0.5 (x, y) extent : 60.75, 105.25, 15.75, 39.25 (xmin, xmax, ymin, ymax) coord. ref. : NA data source : in memory names :
min values : 0, 0, 0, 0, 0, 0 max values : 22.84560, 9.63050, 28.18740, 12.90590, 51.66701, 319.83840

But when I plot the sixth variable, it shows the main heading as VegCX2X0.7, but I want to change it to "Aboveground Biomass Carbon", so I do the following basic code :

plot(try3,6, col=mycol, main=" Aboveground Biomass", legend.args=list(text='Aboveground Carbon Biomass(MgC/ha)', side=4, font=2, line=2.5, cex=0.8))

But the new heading doesnt show up, in fact no heading is not shown. How can i fix this?

1 Answers1

1

Always try to come up with a reproducible example to get the best answer (see here). Suppose this is your raster brick:

library(raster)

#reproducible example
set.seed(987)

# setting up list pf raster stacks
r1 <- raster(nrows = 1, ncols = 1, res = 0.5, xmn = -1.5, xmx = 1.5, ymn = -1.5, ymx = 1.5, vals = runif(36, 1, 5))
r.brk <- brick(lapply(1:6, function(i) setValues(r1,runif(ncell(r1)))))
names(r.brk) <- c("VegC",     "LittC",    "SoilfC",    "SoilsC",     "Total", "VegCX2X0.7")

you can change the name of rasters by:

names(r.brk) <- c("n1",     "n2",    "n3",    "n4",     "n5", "Aboveground Biomass")
plot(r.brk) #plot them in a group by their name as main title

As you have limitations for choosing names, you can also change the main while plotting them as a group:

plot(r.brk, main=c("n1",     "n2",    "n3",    "n4",     "n5", "Aboveground Biomass Carbon"))

or you can change the main plot title while plotting any of them separately as below:

plot(r.brk$Aboveground.Biomass, main="Aboveground Biomass Carbon")
Majid
  • 1,836
  • 9
  • 19