How can I fix the following code
alpha <- 1
draws <- 15
dimen <- 10
require(MCMCpack)
x <- rdirichlet(draws, rep(alpha, dimen))
require(ggplot2)
dat <- data.frame(item=factor(rep(1:10,15)),
draw=factor(rep(1:15,each=10)),
value=as.vector(t(x)))
ggplot(dat,aes(x=item,y=value,ymin=0,ymax=value)) +
geom_point(colour=I("blue")) +
geom_linerange(colour=I("blue")) +
facet_wrap(~draw,ncol=5) +
scale_y_continuous(lim=c(0,1)) +
opts(panel.border=theme_rect())
to not to get this empty plot:
I assume you get the following error message:
If so, this should be stated in your question.
Using the current version of ggplot2 (0.9.3.1) and
theme()
instead ofopts()
, this script:...gives this plot:
Is this what you want?
You may also wish to check the
scales
argument in?facet_wrap
, andcoord_cartesian
as an alternative to set limits inscale_y_continuous