[R] limit ranges in hexbin

Lutz Gehlen lrg_ml at gmx.net
Mon Dec 12 03:02:20 CET 2011

Hello everybody,
I hope you can give me some help with limiting the ranges in x, y, and z for a 
hexbin plot. All I have found on the net is an unanswered message to this list 
from last year, so I hope my problem is not too stupid.

I would like to plot some data using hexagonal binning. Currently, I am doing 
the following:

data<-scan("input.dat", what = list('numeric', 'numeric'))
hbin<-hexbin(x, y)

That does get me a hexgonal bin plot, so far, so good. My problem now is 
1) Some of my data points have really high values in x and y, and I would like 
to exclude them. First idea was to set xbnds and ybnds parameters for hexbin 
like this.

hbin<-hexbin(x, y, xbins = 50, xbnds = c(0, 5000))

However, hexbin does not like it: Error in hexbin(x, y, xbins = 50, xbnds = 
c(0, 5000)) : 'xbnds' must encompass range(x). Is there some other way to 
enforce limits in x and y? Otherwise, I could, of course, prefilter my data.

2) The second problem is limiting the count values. My counts are strongly 
dominated by one bin. So I end up with that bin being black and some others 
very light gray. I would like to set the black value to some lower number. Of 
course, some bins will be saturated then, but for that I will get better 
contrast in the range I am interested in.

Thanks a lot for your help,

More information about the R-help mailing list