geom_errorbarh width doesn't seem to have an effect

182 views
Skip to first unread message

MC

unread,
Apr 22, 2010, 2:47:55 PM4/22/10
to ggplot2
I would like to get the same effect at the ends of the error bar with
geom_errorbarh that I get with geom_errorbar.

I use the following code to generate the data:

n <- 20;
y <- rep(NA,n);
x <- rep(NA,n);
ystd <- rep(NA,n);
xstd <- rep(NA,n);
ywt <- rep(NA,n);
xwt <- rep(NA,n)

for (j in 1:20){
c <- floor(runif(1,min=6,max=25));
yt <- runif(c,min=1,max=100);
xtt <- 2*yt;

yt <- yt + rnorm(c,sd=15);
xt <- xtt + rnorm(2*c,sd=15);

y[j] <- mean(yt);
x[j] <- mean(xt);

ystd[j] <- sd(yt);
xstd[j] <- sd(xt);

ywt[j] <- c;
xwt[j] <- 2*c;
}

then I use the following code to generate the plot



library(ggplot2);
p <- ggplot(data.frame(x=x,y=y,ystd=ystd,xstd=xstd,ywt=ywt,xwt=xwt),
aes(x,
y,
size=sqrt(xwt*ywt)));
p <- p + layer(geom='point');
p <- p + geom_errorbar(aes(ymax=y+ystd,
ymin=y-ystd),
colour='blue',
size=.01,
width=5);
p <- p + geom_errorbarh(aes(xmax=x+xstd,
xmin=x-xstd),
colour='red',
size=.01,
width=5);
p;

--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442

To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

hadley wickham

unread,
Apr 23, 2010, 10:51:17 AM4/23/10
to MC, ggplot2
Try using height instead of width.
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

MC

unread,
Apr 23, 2010, 11:43:39 AM4/23/10
to ggplot2
I tried the using height but it still won't put the little
perpendicular ends for geom_errorbarh
> Department of Statistics / Rice Universityhttp://had.co.nz/
>
> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example:http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options:http://groups.google.com/group/ggplot2

takahashi kohske

unread,
Apr 23, 2010, 12:12:43 PM4/23/10
to MC, ggplot2
Hi

If you specify height in aes, then it looks like to work.

p <- p + geom_errorbarh(aes(xmax=x+xstd,
xmin=x-xstd, height=5),
colour='red',
size=.1,
);

I don't know if this is bug, but probably this is undesired behavior
because width specified outside aes can work in geom_errorbar.


2010/4/24 MC <munawar....@googlemail.com>:

hadley wickham

unread,
Apr 23, 2010, 12:17:17 PM4/23/10
to takahashi kohske, MC, ggplot2
Yup, it's a bug and it'll be fixed in the next version of ggplot2.
Hadley
Reply all
Reply to author
Forward
0 new messages