Answers.Body: <p>Did you try the <code>fill</code> argument?</p>
  
  <p>Something like this:</p>
  
  <pre><code>track &lt;- AnnotationTrack(start=c(1,5,7), end=c(2,6,10), strand=c('*','*','*'), stacking="dense", showFeatureId=TRUE, id=c('red','blue', 'red'), fill=c('red','blue', 'red'))
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-15T10:08:37.210Z
Answers.Text: Thanks, seems to work, can't believe I missed that! What colours are accepted as arguments for `fill`?
Answers.UserDisplayName: Chris_Rands
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-15T10:11:56.833Z
Answers.Text: Probably all colors, [here](http://sape.inf.usi.ch/quick-reference/ggplot2/colour) a list of color names.
Answers.UserDisplayName: benn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-15T10:59:52.307Z
Answers.Text: @Chris_Rands see `?plotTracks` for the options accepted by `plotTracks` which will then refer you to `?settings` for the various things you can tweak (long, long documentation). Finally, `availableDisplayPars(track)` will show you what you can set for `track`.
Answers.UserDisplayName: terdon
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-15T10:02:28.663Z
Answers.LastActivityDate: 2017-11-15T10:02:28.663Z
Answers.UserDisplayName: benn
Body: <p>I'm learning the Gviz bioconductor package, I generate a plot as follows:</p>
  
  <pre><code>library(Gviz)
  track &lt;- AnnotationTrack(start=c(1,5,7), end=c(2,6,10), strand=c('*','*','*'), stacking="dense", showFeatureId=TRUE, id=c('red','blue', 'red'))
  pdf(file=paste("test","pdf", sep="."))
  plotTracks(track)
  dev.off()
  </code></pre>
  
  <p><code>test.pdf</code> looks like this: <a href="https://i.sstatic.net/bXZPG.png" rel="noreferrer"><img src="https://i.sstatic.net/bXZPG.png" alt="enter image description here"></a></p>
  
  <p>However, what I want is for the boxes to be coloured rather than labelled with the colour word, how to do this?</p>
  
  <p>Note that my real example is much more complex than this.</p>
  
Tags: <r><bioconductor><gviz>
Title: How can I colour boxes in Gviz AnnotationTrack in R?
ThreadText: # How can I colour boxes in Gviz AnnotationTrack in R?
  
  (Asked by: username_0 on 2017-11-15)
  
  I'm learning the Gviz bioconductor package, I generate a plot as follows:
  
  ```
  library(Gviz)
  track <- AnnotationTrack(start=c(1,5,7), end=c(2,6,10), strand=c('*','*','*'), stacking="dense", showFeatureId=TRUE, id=c('red','blue', 'red'))
  pdf(file=paste("test","pdf", sep="."))
  plotTracks(track)
  dev.off()
  
  ```
  
  `test.pdf` looks like this: [![enter image description here](https://i.sstatic.net/bXZPG.png)](https://i.sstatic.net/bXZPG.png)
  
  However, what I want is for the boxes to be coloured rather than labelled with the colour word, how to do this?
  
  Note that my real example is much more complex than this.
  
  **Tags:** r, bioconductor, gviz
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-11-15. Score: 8 | Accepted answer
  
  Did you try the `fill` argument?
  
  Something like this:
  
  ```
  track <- AnnotationTrack(start=c(1,5,7), end=c(2,6,10), strand=c('*','*','*'), stacking="dense", showFeatureId=TRUE, id=c('red','blue', 'red'), fill=c('red','blue', 'red'))
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks, seems to work, can't believe I missed that! What colours are accepted as arguments for `fill`?  
  > **username_1**: Probably all colors, [here](http://sape.inf.usi.ch/quick-reference/ggplot2/colour) a list of color names.  
  > **username_2**: @username_0 see `?plotTracks` for the options accepted by `plotTracks` which will then refer you to `?settings` for the various things you can tweak (long, long documentation). Finally, `availableDisplayPars(track)` will show you what you can set for `track`.  
  
  ---
  
  