2

I have this set of discrete data (O.D.) which are referred to some of my samples:

SAMPLE     O.D.600nm
I (D+G)       0.3
II (D+G)      0.3
III (D+G)     0.28
VII (YPD)     0.4
VIII(YPD)     0.42
IX (YPD)      0.388

And I made a pretty basic Bar chart out of it using the following ggplot code:

ggplot(myData, aes(SAMPLE, O.D.600nm, fill=SAMPLE)) +
  geom_bar(stat = "identity", width = 0.5)+
  scale_fill_manual(values=c("lightblue", "lightblue", "lightblue", "orange", "orange", "orange"))+
  geom_text(aes(label=O.D.600nm),position="stack",vjust=1)+
  ylim(0,0.625)

This is my result:

enter image description here

So, my question is the following: is it possible to highlight/colour the whole area of the chart that goes from the O.D. 0.3 to the O.D. 0.6?

Axeman
  • 32,068
  • 8
  • 81
  • 94
mormino
  • 21
  • 1
  • Do you mean the background area? – LAP Dec 13 '17 at 14:01
  • 3
    See [`annotate`](http://ggplot2.tidyverse.org/reference/annotate.html) for some examples, including a rectangle one. Basically you want something like `+ annotate('rect', xmin = -Inf, xmax = Inf, ymin = 3, ymax = 6, alpha = .2)` – Axeman Dec 13 '17 at 14:02
  • 3
    Possible duplicate of [How to highlight time ranges on a plot?](https://stackoverflow.com/questions/4733182/how-to-highlight-time-ranges-on-a-plot) – Axeman Dec 13 '17 at 15:12
  • @Axeman Yes!! Thank you so much, that was exactly what I wanted! – mormino Dec 13 '17 at 16:02
  • Possible duplicate of [Draw multiple squares with ggplot](https://stackoverflow.com/questions/15903868/draw-multiple-squares-with-ggplot) – Jan Boyer Dec 13 '17 at 20:21

0 Answers0