title: How to make an R heatmap that fills up a PNG image (no background)
body: <p>I want to explicitly set the pixel size of a heatmap to the number of rows and columns being plotted (actually it's a multiple of that, e.g. here 15 square pixels per point). But no matter what I try, I get an annoying background. </p>
  
  <pre><code>data = as.matrix(datasets::crimtab)
  png(filename = "foo.png", width = dim(data)[1]*15, height = dim(data)[2]*15)
  heatmap(data, Colv=NA, Rowv=NA, labRow=FALSE, labCol=FALSE, scale="row",
          margins = c(0, 0), useRaster=TRUE, mai=c(0,0,0,0), mar=c(0,0,0,0),
          bty="n", oma=c(0,0,0,0), omi=c(0,0,0,0), pty="m", plt=c(0,1,0,1), 
          mgp=c(0,0,0), ann=FALSE, xaxs="i", yaxs="i")
  dev.off()
  </code></pre>
  
  <p>I tried with and without a separate <code>par()</code> call.</p>
  
  <pre><code>png(filename = "bar.png", width = dim(data)[1]*15, height = dim(data)[2]*15)
  par(mai=c(0,0,0,0), mar=c(0,0,0,0),
      bty="n", oma=c(0,0,0,0), omi=c(0,0,0,0), pty="m", plt=c(0,1,0,1), 
      mgp=c(0,0,0), ann=FALSE, xaxs="i", yaxs="i")
  heatmap(data, Colv=NA, Rowv=NA, labRow=FALSE, labCol=FALSE, scale="row",
          margins = c(0, 0), useRaster=TRUE)
  dev.off()
  </code></pre>
  
  <p>I don't know if it's possible to do an R fiddle with the png device.</p>