geom_histogram with facet_grid - only unique values counted?

75 views
Skip to first unread message

Freddie Partridge

unread,
Apr 23, 2012, 11:53:50 AM4/23/12
to ggp...@googlegroups.com
Example code:

library(ggplot2);
result <- c(133.3333, 142.8571, 130.4348, 139.5349, 136.3636, 139.5349, 139.5349, 139.5349, 
           122.449, 142.8571, 142.8571, 130.4348, 139.5349, 142.8571, 139.5349, 
           142.8571, 120, 136.3636, 139.5349, 133.3333, 136.3636, 127.6596, 
           139.5349, 139.5349, 139.5349, 136.3636, 127.6596, 139.5349, 139.5349, 
           122.449, 136.3636, 139.5349, 136.3636, 130.4348, 139.5349, 136.3636, 
           127.6596, 136.3636, 127.6596, 130.4348, 122.449, 127.6596, 136.3636, 
           142.8571, 136.3636, 136.3636, 136.3636, 127.6596);
time <- rep("10mins",48);
df<-data.frame(time, result);

ggplot(df,aes(x=result)) + 
  geom_histogram(binwidth=10);

ggplot(df,aes(x=result)) + 
  geom_histogram(binwidth=10) +
  facet_grid(~time);

ggplot(unique(df),aes(x=result)) + 
  geom_histogram(binwidth=10);


The first plot is as expected, with the highest column count >30.
In the second plot I plot this data as part of a facet_grid - the highest count is now only 4. (For simplicity here I only supply data for one facet, the problem is the same with a complete dataset) 
The plot is in fact the same as if I plot only the unique values, as in the third plot.

Is this the expected output?

Many thanks,

Freddie 






> sessionInfo()
R version 2.14.2 (2012-02-29)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

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

other attached packages:
[1] scales_0.2.0  gridExtra_0.9 ggplot2_0.9.0

loaded via a namespace (and not attached):
 [1] colorspace_1.1-1   dichromat_1.2-4    digest_0.5.2       MASS_7.3-17        memoise_0.1       
 [6] munsell_0.3        plyr_1.7.1         proto_0.3-9.2      RColorBrewer_1.0-5 reshape2_1.2.1    
[11] stringr_0.6        tools_2.14.2  


Freddie Partridge

unread,
Apr 23, 2012, 1:25:54 PM4/23/12
to ggp...@googlegroups.com
ok I think this may be due to the fixed bug https://github.com/hadley/ggplot2/issues/443

If so please ignore, will wait for 0.9.1


Winston Chang

unread,
Apr 23, 2012, 2:17:05 PM4/23/12
to Freddie Partridge, ggp...@googlegroups.com
You can install the development version (with the bug fix) now:
On Mon, Apr 23, 2012 at 12:25 PM, Freddie Partridge <fpart...@gmail.com> wrote:
ok I think this may be due to the fixed bug https://github.com/hadley/ggplot2/issues/443

If so please ignore, will wait for 0.9.1


--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

Reply all
Reply to author
Forward
0 new messages