Search code examples
rplotlevelplot

Change width of levelplot in R


I have created a levelplot() in R using a data set with 5 rows and 50 columns.

rgb.palette <- colorRampPalette(c("green", "red"), space = "Lab")
levelplot(mat, col.regions=rgb.palette, xlab = "Risk Level", ylab = "Zones", main = "Risk  Profile")

The result looks like this: enter image description here

Can someone please advice, how can I expand the plot horizontally and the labels of x-axis to be visible clearly?


Solution

  • Bu default, levelplot() use the isometric aspect so one unit in x equals one unit in y. You can change the default with

    levelplot(mat, col.regions=rgb.palette, 
        xlab = "Risk Level", ylab = "Zones", main = "Risk Profile", 
        aspect="fill")