How to create and position a custom color scale in R
just a simple example below
# create a colorramp pallete pal <- colorRampPalette(c("red", "yellow", "lightgreen","#66FFCC","darkblue","darkblue"))(3300) # create an empty plot plot(-1,-1,xlim=c(0,10),ylim=c(0,10),xlab="my x-axis",ylab="my y-axis") # create new figure on top of old one with different bounds par(new=T,fig=c(0.6,0.85,0.02,0.77)) # create x, y z values for your image x=1 z=matrix(1:1500,nrow=1) y=seq(0,10,len=1500) # plot the image image(x,y,z,col=pal,axes=FALSE,xlab="",ylab="",labels=F) # enable text outside the drawing area par(xpd=NA) # add some text text(1,11,"(mm)") # add an axis on the left side axis(4,las=1,seq(0,10,1),at=seq(0,10,1))
Click here to see the result in Rfiddle.