[R] how to add annotate horizontal line between bars and decrease size and space between bars?

Ana Marija @okov|c@@n@m@r|j@ @end|ng |rom gm@||@com
Thu Jan 16 21:51:12 CET 2020


Hello,

I have a code like this:

p <- ggplot(data = df, aes(x = Name, y = prop, fill = Name)) +
  geom_bar(stat = "identity") +
  labs(x = "", y = "EQTL / gene") +
  scale_fill_brewer(palette="Greens",name = "Number of cis EQTL") +
  theme(legend.position = "none")
p
which produces the attached plot.
How do I add a horizontal lines in between middle points of two bars
above which I would have written: p = 2e-16

I tried adding this:

> p+ annotate("text", x = 1.5, y = 1.2, label = "p = 2e-16", size = 3.5) +
+   annotate("rect", xmin = 1, xmax = 2, ymin = 1, ymax =1,
alpha=0.3,colour = "black")
Error in annotate("text", x = 1.5, y = 1.2, label = "p = 2e-16", size = 3.5) :
  unused arguments (x = 1.5, y = 1.2, label = "p = 2e-16", size = 3.5)

Also how do I decrease size of these two bars?

Thanks
Ana

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2020-01-16 at 2.50.42 PM.png
Type: image/png
Size: 50677 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20200116/1b2a0e76/attachment.png>


More information about the R-help mailing list