lundi 26 mai 2014

Combine two y axes in R


Vote count:

0




I have a dataset uploaded here... My_Data_set.OUT


This is what I am doing



b<- read.table("file_name.out")
EXP <- 2
names(b) <- paste("name_",1:30)
gg2 <- subset((aggregate(cbind(name_4)~name_1+name_2+name_3,b, FUN=mean)),(aggregate(cbind(name_4)~name_1+name_2+name_3,b, FUN=mean))$name_1 == c(1:EXP))
plot_exp <-
function(i){
dat <- subset(gg2,name_1 == i )
ggplot(dat,aes(x=name_3, y=name_4, fill = name_2)) +
geom_point(aes(color = name_2),size = 3) + geom_smooth(stat= "smooth" , alpha = I(0.01))
}
ll <- lapply(seq_len(EXP), plot_exp)
do.call(grid.arrange, ll)


The output of this is two graphs one below the other.


--I want to have a distinct Y-axes for both but a single x-axis.


--Also I want to name the two graphs distinctly here for ex: EXP1, EXP2


--And I want to have distinct color for distinct name_2 columns (As you can see the plots are plotted for all the name_2 distinct entries)


--Again please help in naming the legends based on name_2 column, and also how to change the x and y axes names externally means outside the ggplot command once set.


Thanks in Advance.



asked 25 secs ago






Aucun commentaire:

Enregistrer un commentaire