Reputation: 87
I have plotted a stack of raster using the function 'levelplot' script as below:
library(raster)
library(rasterVis)
ras <- list.files("/filepath/", pattern = "\\.tif$", full=TRUE)
s <- stack(ras)
> levelplot(s, colorkey = list(space ="bottom",height=1, width=1),
names.attr=c("2011","2012","2013", "2014")))
The problem with the plot is that the label of x-axis label 'Longitude' overlaps with the colorbar/ colorkeys of the plot. Is it possible to move the position of colorkeys a little below the label 'Longitude'?
Thanks
Upvotes: 2
Views: 1146
Reputation: 3
I found another solution for this problem that adds padding around the x-axis label. Just add this as additional argument to your levelplot() function and adjust the padding:
par.settings = list(layout.heights = list(xlab.key.padding = 1))
The source is this thread, where you can find some other ideas:
levelplot: how to add space between colorkey and x-axis label
Upvotes: 0
Reputation: 87
@Khaynes Answer to the question:
levelplot(s, colorkey = list(space = "bottom", height = 1, width = 1),
names.attr = c("2011", "2012", "2013", "2014"),
xlab = list(label = "Longitude", vjust = -.2)))
The result->
All Thanks to @Khaynes
Upvotes: 0
Reputation: 1986
You can adjust this with the vjust
parameter in the xlab
list ...
levelplot(s, colorkey = list(space = "bottom", height = 1, width = 1),
names.attr = c("2011", "2012", "2013", "2014"),
xlab = list(label = "Longitude", vjust = -.2)))
Upvotes: 3