# Best way to draw heatmap for publication

[This article was first published on

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Here are two tips I can share if you were also working on a big dataset towards a high quality heatmap:**One Tip Per Day**, 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.

1. Don’t generate PDF using pheatmap() or heatmap.2() as (i) the file is unnecessarily SUPER large if you have a lot of data points in the heatmap, so that you can kill your Illustrator; (ii) annoying grey boxes added to the grip (see here). Use basic image() with zero margins (e.g. par(mar=c(0,0,0,0))) to generate high-resolution PNG (or JPEG, TIFF) and place in Adobe Illustrator. You can freely add legend/annotation there easily.

2. When you use image(), rotate your matrix 90 degree clockwise first, so that the conventional printed layout of the matrix is same what you see in the image (e.g. top-left corner –> x(1,1) in your matrix etc.). An elegant piece of code for clockwise rotation can be found here:

rotate <- function(x) t(apply(x, 2, rev))

To

**leave a comment**for the author, please follow the link and comment on their blog:**One Tip Per Day**.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.