title: how to expand package-created heatmap for aesthetics
body: <p>I have installed a package (CellCODE) where a function (called "getAllSPVs") has been defined that allows me to specify, as one of the arguments
  that the output be in a plot format:</p>
  
  <pre><code>getAllSPVs(data, plot=TRUE)
  </code></pre>
  
  <p>However the function has been defined in a way that the legend covers a portion of the graph and the writing both in the legend and on the axes is too small to read:</p>
  
  <p><a href="https://i.stack.imgur.com/LLDg2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LLDg2.png" alt="enter image description here"></a></p>
  
  <p>I have tried to manually make re-define the function so that I can move the legend  off of the plot and make the writing more legible. The result of my modifications is as follows:</p>
  
  <p><a href="https://i.stack.imgur.com/txgqe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/txgqe.png" alt="enter image description here"></a></p>
  
  <p>but I only managed to move the legend off of the graph to a certain extent and it is still partially covering the dendogram. I also changed the size of the writing on the Y-axis (how is specified below- still working on this such that it doesn't jumbled). The arrows indicate the space that I would like the graph to perforate. But no matter what I do with the margins the heat map just won't expand.</p>
  
  <p>Below is the code that I modified to make the adjustments that I achieved so far (please pay particular attention to the parts that I have commented as #####IMPORTANT):</p>
  
  <pre><code> getAllSPVs&lt;-function (data, plot = F) #output in form of plot when specified in command is set to TRUE
    {
  
    (.......)
    if (plot) {
      parlast = par(mar=c(1,1,1,1),no.readonly = T) ####IMPORTANT inserted the par argument here.
      datatmp = rbind(data[rownames(dataTag), ], t(SPVs))##### Don't Understand
      datatmp = resid(datatmp, grp)                          # any of this
      labGenes = c(apply(dataTag, 1, function(x) {           # but it might be
          which(x &gt; 0)[1]                                    # important for
      }), rep(ncol(dataTag) + 1, ncol(SPVs)))################# expanding the heatmap
  
      mycol = c(rainbow(ncol(dataTag))[sample(ncol(dataTag))], 
                "black")
      corplot(datatmp, usecordist = T, ColSideColors = mycol[labGenes], 
              labRow = c(rep("", nrow(dataTag)), colnames(dataTag)), 
              density.info = "none", cexRow = 2, dendrogram = "column", #changed cexRow to value of '2'
              key = F)
      par(mar=c(0,0,0,0)) ##### IMPORTANT:changed from the original par(mfg = c(1, par()$mfcol[2]))
      legend("topright", fill = mycol, legend = colnames(dataTag), #specifying it to be top-right (or any other corners doesn't stop it from covering the graph data
             ncol = 1, xpd = NA, cex = 0.7, inset = 0) # here I changed the 'cex' argument to 0.7 from 1
      par(parlast)
  }
  colnames(SPVs) = colnames(dataTag)
  SPVs
  }
  </code></pre>
  
  <p>I have tried playing with the margins of the image as much as possible to expand the heat map such that everything isn't so cluttered...</p>
  
  <p>Overall, my question is how do I re-define the function so that the the plot output of the heat map will be expanded and everything won't be so cluttered....</p>
  
  <p>Can anyone recommend a particular margin ratio such that the white space marked in the above picture can be filled... Or do I need to do something else to get the heat map to expand?</p>
  
  <p>Maybe I'm missing something fundamental and it's not to do with the margins at all...</p>