Filled contour with log-log scale

[This article was first published on [R] tricks, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

A quick workaround to have a filled.contour plot with natural log10-log10 scale (instead of the default natural log scale)
plotmat <- function(mat,main='',factor='M',MeasuredResponse='Coexistence') { X <- as.numeric(rownames(mat)) Y <- as.numeric(colnames(mat)) if(factor=='C') { Y <- Y/0.16 } rownames(mat) <- as.numeric(X) colnames(mat) <- as.numeric(Y) colorFun <- colorRampPalette(c("black","darkblue","blue","green", "orange",'yellow',"red","darkred",'white'))

lX <- log(X, 10) lY <- log(Y, 10)

pretty.X.at <- pretty(range(lX),n=6) pretty.X.lab <- round(10^pretty.X.at,0) pretty.Y.at <- pretty(lY,n=4) pretty.Y.lab <- round(10^pretty.Y.at,2) pretty.Y.lab[pretty.Y.lab>1] <- round(pretty.Y.lab[pretty.Y.lab>1],0) pretty.Y.lab[(pretty.Y.lab>0.1)&(pretty.Y.lab<1)] <- round(pretty.Y.lab[(pretty.Y.lab>0.1)&(pretty.Y.lab<1)],1)

filled.contour(lX,lY,mat, axes=FALSE, frame.plot=TRUE, color=colorFun, ylab= MeasuredResponse, xlab='Time between perturbation events', main=main, key.title=title(main=""), key.axes=axis(4,at=pretty(vmat)), plot.axes={ axis(1,at=pretty.X.at,labels=pretty.X.lab) axis(2,at=pretty.Y.at,labels=pretty.Y.lab) }) }


To leave a comment for the author, please follow the link and comment on their blog: [R] tricks.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)