Skip to content

googlegroupsformatter

bhive01 edited this page Nov 10, 2010 · 14 revisions
asd<-structure(list(variable = structure(1:5, .Label = c("x1", "x2", 
"y1", "y2", "z"), class = "factor"), value1 = c(6.23e-18, 6.43e-18, 
0.228, 0.234, 0.39), value2 = c(-0.28313269, -0.28902094, 0.01739011, 
0.02151179, 0.15097369), variable2 = structure(c(1L, 1L, 2L, 
2L, 3L), .Label = c("x", "y", "z"), class = "factor"), variable3 = c(1L, 
2L, 1L, 2L, 1L)), .Names = c("variable", "value1", "value2", 
"variable2", "variable3"), class = "data.frame", row.names = c(NA, 
-5L))

asd2<-melt(asd[1:3])
colnames(asd2)<-c("x", "y", "z")
asd2$x<-factor(asd2$x, levels=c("z", "y2", "y1", "x2", "x1"))


ggplot(data=asd2)+
geom_bar(aes(x=x, y=z, fill=y), position="dodge")+
geom_hline(y=0, colour="red")+
geom_vline(x=0, colour="red")+
geom_vline(x=1.5, colour="blue")+
geom_vline(x=3.5, colour="green")+
geom_vline(x=5.5, colour="yellow")+
theme_bw()+
coord_flip()+
opts(panel.grid.major=theme_blank()
, panel.grid.minor=theme_blank()
, panel.background=theme_rect(colour="black"))

Note: The ggplot2 wiki is no longer maintained, please use the ggplot2 website instead!

Clone this wiki locally