title: How to arrange column in heatmap.2() based on a predefined order
body: <p>The following code</p>
  
  <pre><code> library("gplots")
   mydata &lt;- mtcars
   hclustfunc &lt;- function(x) hclust(x, method="complete")
   distfunc &lt;- function(x) dist(x,method="euclidean")
  
   heatmap.2(as.matrix(mydata),dendrogram="row",trace="none", margin=c(8,9), hclust=hclustfunc,distfun=distfunc);
  </code></pre>
  
  <p>Generate a heat map that looks like this:</p>
  
  <p><img src="https://i.stack.imgur.com/il0wl.png" alt="enter image description here"></p>
  
  <p>Note that in that figure the column is ordered automatically by the function</p>
  
  <p><code>cyl am vs carb wt drat gear gseq mpg hp dsp</code></p>
  
  <p>What I want to do is to create the same heatmap but with my personally
  defined column order: </p>
  
  <pre><code>cn &lt;- c("wt","qsec","vs","am","gear","carb", "mpg","cyl","disp","hp","drat" )
  </code></pre>
  
  <p>How can I achieve that?</p>
  
  <p>I tried using <code>Colv</code> like this but failed:</p>
  
  <pre><code>heatmap.2(as.matrix(mydata),Colv=cn,dendrogram="row",trace="none", margin=c(8,9), hclust=hclustfunc,distfun=distfunc);
  </code></pre>