[R] editing plot

Ana Marija @okov|c@@n@m@r|j@ @end|ng |rom gm@||@com
Wed Jan 8 20:38:54 CET 2020


I made some progress with this:
ax.11.text <- element_text(size = 10)
ay.11.text <- element_text(size = 10)
p<-ggplot(data=toplot, aes(x=cat, y=props)) +
  geom_bar(stat="identity",width=0.5, fill="steelblue")+
  geom_errorbar(aes(ymin=props-1.96*ses, ymax=props+1.96*ses), width=.1,
                position=position_dodge(.9))  +

  geom_signif(comparisons=list( c("All eQTL", "eQTL from 103 genes"),
                               c("All SNPs", "eQTL from 103 genes")),
              y_position=c(0.065, 0.07), tip_length=0, annotation=c("p
= 0.0012", "p = 0.0023")) +
  scale_y_continuous(breaks=seq(0,.06,by=.01)) +
  xlab("") + ylab("Proportion p-values < 0.05") +
  theme_classic()+
  theme(aspect.ratio = 2/1,axis.text.x = ax.11.text,axis.text.y=ay.11.text)
p

But the spaces between ticks on y axis are too big and the plot is
very elongated. Any advice on how to shrink this vertically?



On Wed, Jan 8, 2020 at 1:14 PM Ana Marija <sokovic.anamarija using gmail.com> wrote:
>
> I used width=0.5, to reduce bar widths and aspect.ratio = 2/1 to
> reduce white spaces between bars but now text on my x axis is
> overlapping and my plot is too elongated, and I don't have those 3
> vertical lines trough bars.
>
> Please advise
>
> p<-ggplot(data=toplot, aes(x=cat, y=props)) +
>   geom_bar(stat="identity",width=0.5, fill="steelblue")+
>   geom_errorbar(aes(ymin=props-1.96*ses, ymax=props+1.96*ses), width=.1,
>                 position=position_dodge(.9))  +
>
>   geom_signif(comparisons=list( c("All eQTL", "eQTL from 103 genes"),
>                                c("All SNPs", "eQTL from 103 genes")),
>               y_position=c(0.065, 0.07), tip_length=0, annotation=c("p
> = 0.0012", "p = 0.0023")) +
>   scale_y_continuous(breaks=seq(0,.06,by=.01)) +
>   xlab("") + ylab("Proportion p-values < 0.05") +
>   theme(aspect.ratio = 2/1,axis.title.x=element_text(size=1,face="bold"))
> p
>
> On Wed, Jan 8, 2020 at 12:52 PM Ana Marija <sokovic.anamarija using gmail.com> wrote:
> >
> > Hello,
> >
> > I have this plot in attach. I was wondering how can I change my
> > plotting code in order to remove these gray horizontal background
> > lines but keep these two vertical lines? These two vertical lines
> > don't need to be gray, can be any other type of lines but they must be
> > at the same place. Also how can I make these two bars narrower?
> >
> > library("ggplot2")
> > p<-ggplot(data=toplot, aes(x=cat, y=props)) +
> >   geom_bar(stat="identity", fill="steelblue")+
> >   geom_errorbar(aes(ymin=props-1.96*ses, ymax=props+1.96*ses), width=.2,
> >                 position=position_dodge(.9))  +
> >
> >   geom_signif(comparisons=list( c("All eQTL", "eQTL from 103 genes"),
> >                                c("All SNPs", "eQTL from 103 genes")),
> >               y_position=c(0.065, 0.07), tip_length=0, annotation=c("p
> > = 0.0012", "p = 0.0023")) +
> >   scale_y_continuous(breaks=seq(0,.06,by=.01)) +
> >   xlab("") + ylab("Proportion p-values < 0.05") +
> >   theme_minimal()
> > p

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2020-01-08 at 1.36.25 PM.png
Type: image/png
Size: 107228 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20200108/9b3ce359/attachment.png>


More information about the R-help mailing list