I'm using the R package 'rastervis' to create a number of multi-plot figures. I'm continually running into alignment issues which I believe are the result of rounding in the plot legends. For example, a plot in which values are rounded to 3 decimal places will be shifted compared to those rounded to just two decimal places. Similarly, if two plots are rounded to 2 d.p. but one has minus values, this will also change the alignment of the plot (presumably because the '-' sign is taking up space within the plot).
I have attached an image of this misalignment and ask whether there is a simple argument which I haven't invoked which will fix the problem. After many search attempts I've been unable to find a solution. I've included some very low-tech red lines on this diagram to show how the plots are misaligned given legends with varying numbers of characters:
I would (ideally) like all plots to be left justified and to be the same width. This would hopefully align the legends too. All of the misalignment I'm experiencing really needs to be pushed to the whitespace on the right of the plot.
Here is a very quickly photo-shopped mock up of the intended result. Note how all plots and legends are aligned with any differences in whitespace given to the right of the plot window. I've done nothing to this image except shift the plots manually either left or right by a few pixels such that they align(i.e. I haven't resized the individual plots, I've just moved them slightly).
Here is a minimum reproducible example. The misalignment isn't quite as severe as my real-world example shown in the images but it is still apparent.
library(raster) library(rasterVis) r1 <- raster(nrow=18, ncol=36) r1 <- runif(ncell(r1)) * 10 r2 <- raster(nrow=18, ncol=36) r2 <- runif(ncell(r1)) * 2.345 r3 <- raster(nrow=18, ncol=36) r3 <- runif(ncell(r1)) * -4 p1 <- levelplot(r1, margin=FALSE, xlab=NULL, ylab=NULL,scales=list(draw=FALSE)) p2 <- levelplot(r2, margin=FALSE, xlab=NULL, ylab=NULL,scales=list(draw=FALSE)) p3 <- levelplot(r3, margin=FALSE, xlab=NULL, ylab=NULL,scales=list(draw=FALSE)) print(p, split=c(1, 1, 1, 3), more=TRUE) print(p2, split=c(1, 2, 1, 3), more=TRUE) print(p3, split=c(1, 3, 1, 3))