1
library(raster)
library(viridis)

data(volcano)
volcanoR <- raster(volcano)

breakpoints <- c(94,100,120,140,160,180,185, 189, 195)

par(mfrow = c(1, 2))

plot(volcanoR, main = "1")
plot(volcanoR, breaks = breakpoints, col = viridis(length(breakpoints) -1), main = "2")

enter image description here

In the plot 2, you see that the legend labels are very close to each other and even overlapping. Is there any way, I can have them not overlapping and equal spaced like in Fig 1.

89_Simple
  • 3,393
  • 3
  • 39
  • 94

1 Answers1

2

This question is not clear to me but I think you can do this using levelplot:

library(raster)
library(lattice)

data(volcano)
volcanoR <- raster(volcano)

breakpoints <- c(94,100,120,140,160,180,185, 189, 195)
levelplot(volcano, at=breakpoints, labels=breakpoints,
          par.settings=list(regions=list(col=topo.colors(8))))

enter image description here

Majid
  • 1,836
  • 9
  • 19