Search code examples
rlevelplot

How can I rotate the origin of a levelplot to the topleft corner?


By default, the levelplot in R has the origin in the bottom left corner; is there a simple way to make it so that it starts in the top left corner instead?

like this: example


Solution

  • I figured out an non-elegant solution by transposing my dataframe, then flipping the columns

    df <- t(df)
    df <- df[,seq(from=ncols(df),to=1,by=-1)] #reversing the columns
    rgb.palette <- colorRampPalette(c("yellow","red"),space="rgb")
    levelplot(data.matrix(df),aspect="iso",scales=list(x=list(rot=45,cex=.7,alternating=2),y=list(cex=.7)),main="title",xlab="",ylab="",col.regions=rgb.palette(300),cuts=500,at=seq(0,3,1)) #alternating=2 flips x axis labels up to top