1

I am wondering how I can add units to my legend here? I would like to add '%' after each number on the legend. I am using base plot in R. There seems to be many solutions for ggplot2, but I can't seem to find this answer for base plot.

My code thus far:

plot(heat_all_rast, col = topo.colors(70))

enter image description here

  • 3
    Could you edit this question to make it reproducible? – jpsmith Aug 18 '23 at 13:25
  • Possible reproducible example: `library(raster); f <- system.file("external/test.grd", package="raster"); r <- raster(f); plot(r, col = topo.colors(70))` – Ben Bolker Aug 18 '23 at 14:03
  • using `legend` function could work. But without reproducible example its hard to say – Golem Aug 18 '23 at 23:30
  • 1
    This seems hard since the `plot()` method for `raster` objects (which is what you seem to be doing) is not very customizable. [This question](https://stackoverflow.com/questions/15813101/controlling-legend-and-colors-for-raster-values-in-r) shows how to plot a raster in `ggplot`, where the color bar would be easier to customize. – Ben Bolker Aug 19 '23 at 00:27

0 Answers0