[R] How do I do a pretty scatter plot using ggplot2?

Jim Lemon jim at bitwrit.com.au
Sun Mar 11 09:55:01 CET 2012

On 03/10/2012 11:37 AM, Michael wrote:
> Hi all,
> I am trying hard to do the following and have already spent a few hours in
> vain:
> I wanted to do the scatter plot.
> But given the high dispersion on those dots, I would like to bin the x-axis
> and then for each bin of the x-axis, plot the quantiles of the y-values of
> the data points in each bin:
> 1. Uniform bin size on the x-axis;
> 2. Equal number of observations in each bin;
> How to do that in R? I guess for the sake of prettyness, I'd better do it
> in ggplot2?
Hi Michael,
While it is not in ggplot2, a variation on the count.overplot function 
might do what you want. This function displays counts of closely spaced 
points rather than the points, but it applies the same area of 
aggregation across the whole plot. Getting the equal x bins is easy, and 
I assume that you mean equal observations within each bin, not across 
all bins. If you are stuck, I can probably hack up something from 


More information about the R-help mailing list