Answers.Body: <p>It is possible with <code>annotation_colors</code> argument :</p>
  <p>First create a list with your conditions and then add the argument :</p>
  <pre><code>annot_colors=list(HealthStatus=c(Cancer=&quot;#F0978D&quot;,Healthy=&quot;#63D7DE&quot;))
      
  pheatmap(heat1,
           annotation_col=df,
           color=colorRampPalette(c(&quot;navy&quot;, &quot;white&quot;, &quot;red&quot;))(50),
           annotation_colors=annot_colors)
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-29T13:35:22.607Z
Answers.LastActivityDate: 2021-11-29T13:35:22.607Z
Answers.UserDisplayName: Basti
Body: <p>I plotted a heatmap</p>
  <p>I want cancer to be red and healthy to be blue</p>
  <pre><code>   pheatmap(heat1, annotation_col=df,color=colorRampPalette(c(&quot;navy&quot;, &quot;white&quot;, &quot;red&quot;))(50))
  </code></pre>
  <p>You are seeing cancer is in blue in annotation, how I can change that<a href="https://i.sstatic.net/iHsFn.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/iHsFn.png" alt="enter image description here" /></a></p>
  
Tags: <r><heatmap>
Title: Changing the order of colors in pheatmap
ThreadText: # Changing the order of colors in pheatmap
  
  (Asked by: username_0 on 2021-11-29)
  
  I plotted a heatmap
  
  I want cancer to be red and healthy to be blue
  
  ```
     pheatmap(heat1, annotation_col=df,color=colorRampPalette(c("navy", "white", "red"))(50))
  
  ```
  
  You are seeing cancer is in blue in annotation, how I can change that[![enter image description here](https://i.sstatic.net/iHsFn.png)](https://i.sstatic.net/iHsFn.png)
  
  **Tags:** r, heatmap
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-11-29. Score: 5 | Accepted answer
  
  It is possible with `annotation_colors` argument :
  
  First create a list with your conditions and then add the argument :
  
  ```
  annot_colors=list(HealthStatus=c(Cancer="#F0978D",Healthy="#63D7DE"))
      
  pheatmap(heat1,
           annotation_col=df,
           color=colorRampPalette(c("navy", "white", "red"))(50),
           annotation_colors=annot_colors)
  
  ```
  
  
  ---
  
  