plot 4 different plots inside 1 pdf
- by ifreak
I have 2 data frames which i want to generate 3 plots from them and place them inside 1 pdf file as a single column.
i want all the plots to have the same x-axis limits(basically the same x-axis) even thought they differ in the name and how they were obtained.
the dataframes looks something like that:
d1       
     X          Y       Z
0.04939317 -0.4622222  13651
0.03202451 -0.4261000  13401
0.09950793 -0.3233025  13151
0.11548556 -0.4637981  12486
0.09817597 -0.4751886  12236
0.15770701 -0.5819355  11986
and d2
   V0  V1   V2    V3   sign
   1   1  0.379 0.612   pos
   2   1  0.378 0.620   pos
   3   1  0.578 0.571   neg
   4   1  0.978 0.561   pos
   5   1  0.758 0.261   neg
   6   1  0.378 0.126   neg
P.S : both data frames are bigger than this, this is only a part of them
V0, V1 and Z range from 1 to 20000
the plots that i created are :
From d2
d2plot=ggplot(d1, aes(V0,V1, fill=sign)) + geom_tile()+ scale_fill_manual(values = c("neg" = "yellow", "pos"="red")) +geom_vline(xintercept =10000 ) +geom_text(mapping=aes(x=10000,y=0, label="Stop"), size=4, angle=90, vjust=-0.4, hjust=0)
From d1
d1plot = ggplot(d2) + geom_errorbarh(aes(x=z,xmin=z-50,xmax=z+50, y=Y, height = 0.02),color="red")+ opts(legend.position = "none")  +geom_vline(xintercept = 10000) +geom_text(mapping=aes(x=10000,y=-0.3, label="Stop"), size=4, angle=90, vjust=-0.4, hjust=0)
i've tried grid.arrange(d1plot,d2plot,ncol=1) but the x-axis is different for each plot, i tried changing the aspect ratio, but this will change the y-axis ..i've also tried to use facet_wrap but the problem that my x-axis values have different values, i just want the limits and breaks to be the same and the plots all be aligned in 1 column based on 1 x-axis to comapre the value of the statistical methods in an easy way.