Michael
2012-Mar-12 01:54 UTC
[R] to Michael ... Re: How do I do a pretty scatter plot using ggplot2?
Hi Michael, I am trying the solution you've suggested below: DAT <- data.frame(x = runif(1000, 0, 20), y = rnorm(1000)) DAT$xbin <- with(DAT, cut(x, seq(0, 20, 2))) p <- ggplot(DAT, aes(x = x, y = y)) + geom_point(alpha = 0.2) + stat_quantile(aes(colour = ..quantile..), quantiles = seq(0.05, 0.95, by=0.05)) + facet_wrap(~ xbin, scales = "free") print(p) ----------------------- But my big problem is: I don't know how to modify the code above to do it for "equal # of points" in each bin along the x-axis? i.e. the 2nd case in the original problem: 2. Equal number of observations in each bin; ? Thanks a lot! [[alternative HTML version deleted]]
Michael
2012-Mar-12 02:02 UTC
[R] to Michael ... Re: How do I do a pretty scatter plot using ggplot2?
And also, no matter how I changed the "quantiles = seq(0.05, 0.95, by=0.05))" line, the number of lines in each bin and the number of legends on the right side of the each plot are different... What's the catch? Am I missing something here? I thought the number of quantile lines and the number of legends should be exactly the same, no? On Sun, Mar 11, 2012 at 8:54 PM, Michael <comtech.usa@gmail.com> wrote:> Hi Michael, > > I am trying the solution you've suggested below: > > DAT <- data.frame(x = runif(1000, 0, 20), y = rnorm(1000)) > DAT$xbin <- with(DAT, cut(x, seq(0, 20, 2))) > > p <- ggplot(DAT, aes(x = x, y = y)) + geom_point(alpha = 0.2) + > stat_quantile(aes(colour = ..quantile..), quantiles = seq(0.05, 0.95, > by=0.05)) + facet_wrap(~ xbin, scales = "free") > print(p) > ----------------------- > > But my big problem is: I don't know how to modify the code above to do it > for "equal # of points" in each bin along the x-axis? > > i.e. the 2nd case in the original problem: > > 2. Equal number of observations in each bin; > > ? > > Thanks a lot! > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]