[R] how to add p values to bar plot?
Jim Lemon
drj|m|emon @end|ng |rom gm@||@com
Sat Sep 28 23:43:01 CEST 2019
Hi Ana,
You seem to have a p-value at the top of the second plot. Do you just
want that p-value in a different place?
My first guess would be the "annotate" argument. Say you wanted your
p-value in the middle of the plot.
# your ggplot line
p+annotate("text",x=1.5,y=0.05,label="p = 1.6x10-16")
p
Note: untested
Jim
On Sat, Sep 28, 2019 at 6:52 PM Ana Marija <sokovic.anamarija using gmail.com> wrote:
>
> Hi,
>
> I have a bar plot (green colors in attach) which I made with this:
>
> library(ggplot2)
> df <- data.frame("prop" = c(7.75,70.42), "Name" = c("All Genes","RG Genes"))
> p<-ggplot(data=df, aes(x=Name, y=prop,fill=Name)) +
> geom_bar(stat="identity")+ labs(x="", y = "Proportion of cis
> EQTLs")+ scale_fill_brewer(palette="Greens") +
> theme_minimal()+theme(legend.position = "none")
> p
>
> What do I need to change in my plot so that I have plot with p value
> shown on the 2nd attached figure (gray and blue)?
>
> Thanks
> Ana
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list