 <p>I am not sure if I understand you right, but does a tranpose of your matrix do the job?</p> <p>Here is an example:</p> <pre><code> require(gplots) data(mtcars) x &lt;- as.matrix(mtcars) heatmap.2(x) </code></pre> <p><img src="https://i.stack.imgur.com/4Bue0.png" alt="enter image description here"></p> <pre><code># transpose the matrix heatmap.2(t(x)) </code></pre> <p><img src="https://i.stack.imgur.com/5R8AF.png" alt="enter image description here"></p>