Thursday, May 2, 2013

RG#105: Line range or Crossbar plot


set.seed (1234)
require(ggplot2)
Xv <- c(rnorm (500, 10,3), rnorm (500, 50, 20), rnorm (500, 70, 20))
Yv <- c(rnorm (500, 10,3), rnorm (500, 70, 5), rnorm (500, 30, 5))
myd <- data.frame (Xv, Yv )

m <- ggplot(myd, aes(x = Xv, y = Yv)) +
  geom_point() + geom_density2d() + theme_bw()
  
m


myd <- data.frame (Xv = c("A", "B", "C", "E", "F"), Yv = c( 35, 35, 69, 15, 60),
                    errs = c(5, 10, 3, 5, 12))

se <- ggplot(myd, aes(Xv, Yv,
  ymin = Yv - errs, ymax= Yv + errs, colour = Xv))
  
# line range plot 

se + geom_linerange() + theme_bw()





se + geom_linerange()  + coord_flip() + theme_bw()

se + geom_crossbar(width = 0.5) + theme_bw()



No comments:

Post a Comment

Note: Only a member of this blog may post a comment.