4

I have the following R code that generates a plot.

b <- c(0,30,60,90,120,150,180)
rast <- raster("study.area.accessibility.tif")
r <- clamp(rast, 0, 180) 

plot(r, 
     col=topo.colors(length(b)), 
     breaks = b
     )

enter image description here

I want that last break's text to be technically accurate.
That is, instead of 180, I want it to be 180+ or >180.

1 Answer 1

6

You could set lab.breaks along with breaks.

# please ignore this part ###
library(raster)
rast = raster(nrow= 40, ncol= 50)
values(rast) = (1:ncell(rast))/10
# ------------------------###

r <- clamp(rast, 0, 180)

b <- c(0,30,60,90,120,150,180)
lab_b <- c("0","30","60","90","120","150","180+")  # labels for the break

plot(r, 
     col=topo.colors(length(b)), 
     breaks = b,
     lab.breaks = lab_b                             # lab.breaks
)

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.