0

I plotted a raster data using levelplot

> library(raster)
> ras > raster("DEM.tif")
> spplot(S_dub, colorkey = list(space ="right",height=1, width=1, hjust = .3), 
         col.regions = coul,scales=list(alternating=TRUE), 
         xlab = list(label = "Longitude", vjust = -.2),ylab = "Latitude")

enter image description here

The problem is that the colorbar is a bit far from the plot and I want to bring it closer to the plot. Actually, I noticed it happens only when I add the code scales=list(alternating=TRUE). I tried hjust but it doesn't work.

How to reduce the gap/space between the plot and the colorbar?

Lalantra
  • 67
  • 1
  • 11
  • `library(grid)` works here. – M-- Jan 19 '20 at 18:57
  • i tried ```> grid.edit("[.]colorkey.labels$", grep=TRUE, global=TRUE, y=unit(1.5, "mm"))``` but it does not remove the gap whilst the values disappears. Can you help me out? – Lalantra Jan 19 '20 at 19:21
  • https://stackoverflow.com/questions/29344692/custom-placement-of-spplot-legend-in-the-map look at this thread. I'll give it a shot to see if it can be fitted to your problem. In the meantime, please consider providing a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – M-- Jan 19 '20 at 19:36

0 Answers0