Search code examples
rscalerasternetcdf

Changing scale colour to specific number in R


I've uploaded my data onto github here: https://github.com/dschmidt42/Benguela_Chla_Danielle_Schmidt.

To set up my data:

chl_data <- "cmems_mod_glo_bgc_my_0.25_P1M-m_1673881119174.nc"
r <- rast(chl_data)
i <- seq(1, nlyr(r), 3) 
r1 <- r[[i]]
vm <- tapp(r1, "months", var)

Here are the resulting plots:

titles <- c("January", "February", 
            "March", "April", 
            "May", "June", 
            "July", "August", 
            "September", "October",
            "November", "December")
plot(vm, main = titles)

enter image description here

As you can see, the scales are all the same though they have different values. How can I change it so that 4.0 on one graph is not the same as 1.5 on another?


Solution

  • You can try setting the breaks manually and the type of the rasters as continuous.

    library(terra)
    plot(vm, 
         main = titles,
         type = "continuous",
         breaks = seq(0,4,0.5))