replicated values on y-axis in geom_pointrange / geom_crossbar

12 views
Skip to first unread message

Stefan

unread,
Mar 1, 2012, 6:55:58 PM3/1/12
to ggplot2
Hi all,

I have the following problem:

df<-data.frame(treatment=c('A','B','C','D'),
outcome=c(266.5,268.3,267.5,268.8), se=c(0.2449,0.2136,0.1872,0.2347))

> df
treatment outcome se
1 A 266.5 0.2449
2 B 268.3 0.2136
3 C 267.5 0.1872
4 D 268.8 0.2347

Instead of using bar graphs I'd like to present the data as
pointranges or crossbars:

ggplot(df, aes(x=treatment, y=outcome))
+geom_pointrange(aes(ymin=outcome-se, ymax=outcome+se))

When looking at the y-axis the value 268 is repeated 3 times. Do you
have any explanations for that? I probably just missing something
obvious?!

Thanks!

> sessionInfo()
R version 2.14.1 (2011-12-22)
Platform: i386-apple-darwin9.8.0/i386 (32-bit)

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets grid
methods
[8] base

other attached packages:
[1] scales_0.1.0 ggplot2_0.8.9 proto_0.3-9.2 reshape_0.8.4
plyr_1.7.1

loaded via a namespace (and not attached):
[1] colorspace_1.1-1 dichromat_1.2-4 munsell_0.3
[4] RColorBrewer_1.0-5 stringr_0.6

Ben Bond-Lamberty

unread,
Mar 1, 2012, 9:10:23 PM3/1/12
to ggplot2
Stefan,
Your example works fine (axis shows 267.5, 268.0, etc.) on my system.
Ben

>R version 2.14.1 (2011-12-22)
>Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
...(same)...
>other attached packages:
>[1] ggplot2_0.8.9 proto_0.3-9.2 reshape_0.8.4 plyr_1.6

> --
> 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

Stefan

unread,
Mar 1, 2012, 9:53:17 PM3/1/12
to ggplot2
Thanks for you answer Ben!

But I just tried it again, deleted my workspace and started a new R
session and this is what I get:
http://www.ualberta.ca/~sschreib/

> sessionInfo()
R version 2.14.1 (2011-12-22)
Platform: i386-apple-darwin9.8.0/i386 (32-bit)

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets grid
methods
[8] base

other attached packages:
[1] scales_0.1.0 ggplot2_0.8.9 proto_0.3-9.2 reshape_0.8.4
plyr_1.7.1

loaded via a namespace (and not attached):
[1] colorspace_1.1-1 dichromat_1.2-4 munsell_0.3
[4] RColorBrewer_1.0-5 stringr_0.6



Kohske Takahashi

unread,
Mar 1, 2012, 9:59:21 PM3/1/12
to Stefan, ggplot2
Hi,

ggplot2 0.8.9 doesn't need scales and it may induce some problems.

update your ggplot2 to 0.9 or

detach("package:scales")
and then plot.


2012年3月2日11:53 Stefan <stefan.s...@ales.ualberta.ca>:

--
--
Kohske Takahashi <takahash...@gmail.com>

Research Center for Advanced Science and Technology,
The University of Tokyo, Japan.
http://www.fennel.rcast.u-tokyo.ac.jp/profilee_ktakahashi.html

Stefan

unread,
Mar 1, 2012, 10:15:40 PM3/1/12
to ggplot2
Thanks Kohske!

That did the trick! Awesome! I already updated once to 0.9 and loaded
the scales package via my .Rprofile file. Then 0.9 got pulled and I
had to change everything again but forget to also change the .Rprofile
file. So, for now I will just detach and update once my work is
submitted.

Stefan

On Mar 1, 7:59 pm, Kohske Takahashi <takahashi.koh...@gmail.com>
wrote:
> Hi,
>
> ggplot2 0.8.9 doesn't need scales and it may induce some problems.
>
> update your ggplot2 to 0.9 or
>
> detach("package:scales")
> and then plot.
>
> 2012年3月2日11:53 Stefan <stefan.schrei...@ales.ualberta.ca>:
> Kohske Takahashi <takahashi.koh...@gmail.com>
Reply all
Reply to author
Forward
0 new messages