Still using ggplot 0.9.0. I would try reverting to ggplot 0.8.9 to
see if these are new bugs or if I'm just doing something boneheaded, but
it seems like too much of a nuisance (sorry). Perhaps someone can
confirm whether these work in 0.8.9.
Two issues:
(1) stat_sum() seems to ignore the colour aesthetic ... ?
(2) when I facet_grid I seem to lose the desired behavio(u)r of
stat_sum. This is probably something silly, but I have tried
experimenting with setting the group aesthetic manually and don't seem
to have found a combination that works.
set.seed(101)
d <- data.frame(x=sample(1:5,size=500,replace=TRUE),
y=sample(1:5,size=500,replace=TRUE),
g=sample(c("a","b"),size=500,replace=TRUE))
## creates coloured points
ggplot(d,aes(x,y,colour=g))+geom_point()+facet_grid(.~g)
## no colour -- also no distinctive sizes
ggplot(d,aes(x,y,colour=g))+
stat_sum(aes(group=interaction(x,y,g)))+facet_grid(.~g)
## this works as expected (no colour, different sizes)
ggplot(d,aes(x=x,y=y))+stat_sum()
## aiming for something that looks like this:
library(reshape2)
mm <- melt(with(d,table(x,y,g)))
ggplot(mm,aes(x=x,y=y,colour=g))+geom_point(aes(size=value))+
facet_grid(.~g)
thanks
Ben Bolker
Ben,I can confirm some of the behavior. Plot 3 does have color, but is not different in size on 0.89.Changing group to 1 in that same plot seems to get what you're looking for in 0.89.> sessionInfo()R version 2.14.1 (2011-12-22)Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)locale:[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8attached base packages:[1] grid stats graphics grDevices utils datasets methods baseother attached packages:[1] reshape2_1.2.1 ggplot2_0.8.9 proto_0.3-9.2 reshape_0.8.4 plyr_1.7.1[6] pcaMethods_1.40.0 Rcpp_0.9.9 pls_2.3-0 MASS_7.3-16 Biobase_2.14.0loaded via a namespace (and not attached):[1] digest_0.5.1 stringr_0.6 tools_2.14.1
On 12-01-31 11:58 AM, Brandon Hurr wrote:
> I meant plot 2, changing your interaction to 1 seems to get what you want
> (color and size).
Hmm, if you mean
ggplot(d,aes(x,y,colour=g))+
stat_sum(aes(group=1))+facet_grid(.~g)
then that doesn't appear to work in 0.9.0 either ...
thanks
Ben
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJPKB8tAAoJED2whTVMEyK9GNwH/ijMXowxhxq0rhY8DnVdBAqs
bzSwcHxtBXa6yp7hVlrHtWjNB1OnP/dpRrRqcEWGNf1ODkFus1gajJbY3JOP+prQ
G5ShNFZ7g0nf3GpPAVn3hdm3lqp0MjMc0pHoOZRaNXDGTCg/YyI01dXoFOw3vUmM
AzwvQGMemXuR6keFbNmpTPA1utNkEZdb/58ruGepJRu8M6Sj5Kd4T/+K/RRpLCPC
5ZsQoUMzPJgB9EuazTLMtIYSKmkEiCpBkJWNAljNTVjNX+hUNuWv5yV0g/F8kj6E
2VowwbTM/EkPoOqcaPtwGWhiqWdcHnxHtcdDEDF45IjV7jmAkgSqWjyBYQjEh2k=
=fhdw
-----END PGP SIGNATURE-----
2012/2/1 Brandon Hurr <brando...@gmail.com>:
> --
> 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
--
--
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
I get variable sizes, but not colours, in 0.9.0 with stat_sum() and
facet_wrap():
ggplot(d,aes(x,y,colour=g))+
stat_sum()+facet_wrap(~g)
Maybe I am missing something here. But mm looks like this
str(mm)
'data.frame': 50 obs. of 4 variables:
$ value: Factor w/ 5 levels "1","2","3","4",..: 1 2 3 4 5 1 2 3 4 5 ...
$ NA : Factor w/ 5 levels "1","2","3","4",..: 1 1 1 1 1 2 2 2 2 2 ...
$ NA : Factor w/ 2 levels "a","b": 1 1 1 1 1 1 1 1 1 1 ...
$ NA : int 8 10 7 14 15 8 15 11 9 7 ...
Don't we need variable names for this example?
>
>
> thanks
> Ben Bolker
>
>
>
this works,
ggplot(d,aes(x,y,colour=..n..))+stat_sum()+facet_wrap(~g)
but this does not
ggplot(d,aes(x,y,colour=g))+stat_sum()+facet_wrap(~g)
2012/2/1 Ben Bolker <bbo...@gmail.com>:
--
I don't know what I was dong (reshape 0.8.4, reshape2 1.2.1), but I
wasn't having any trouble getting the melted table with the correct
variable names.
And I don't want to have to create tables and melt manually -- I just
want to be able to use stat_sum() with colour ... (yes, I am aware that
I can get a refund of all the money I have spent on my new copy of
ggplot2 0.9.0 if I'm not satisfied ...)
cheers
Ben
https://github.com/hadley/ggplot2/pull/382
2012/2/1 Ben Bolker <bbo...@gmail.com>:
--
Wow, great.
And thanks, Dennis. Yes, I had some problem to reproduce the last
example. But of course Ben is right, solving this inside is what we want ;-)
Rainer