[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:

library(hexbin)
data<-scan("input.dat", what = list('numeric', 'numeric'))
x<-unlist(data[1])
y<-unlist(data[2])
hbin<-hexbin(x, y)
plot(hbin)

That does get me a hexgonal bin plot, so far, so good. My problem now is 
twofold:
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,
Lutz



More information about the R-help mailing list