[R] Why does smoothScatter clip when xlim and ylim increased?
murdoch at stats.uwo.ca
Sat Feb 6 14:15:43 CET 2010
On 06/02/2010 7:51 AM, Jennifer Lyon wrote:
> Is there a way to get smoothScatter to not clip when I increase the
> ylim parameters?
> Consider the following example:
> #Now if I increase xlim and ylim notice that the plot seems to be
> the former xlim, and ylim boundaries:
> smoothScatter(x1,x2, xlim=c(-5,5), ylim=c(-5,5))
If you follow the links on the help page, you'll see that smoothScatter
uses bkde2D, which has a range.x argument to control the range of the
smoothing. The smoothScatter function never passes the xlim and ylim
values to bkde2D, only to the plotting functions, presumably because the
author expected you to use them to limit the range, not extend it.
You can get the behaviour you want with specified xlim and ylim by
modifying one line in smoothScatter:
map <- grDevices:::.smoothScatterCalcDensity(x, nbin, bandwidth)
map <- grDevices:::.smoothScatterCalcDensity(x, nbin, bandwidth,
(You can use fix(smoothScatter) to edit your own local copy of
smoothScatter and make this change.)
However, this messes up the default plot, so a better patch would be
needed to permanently fix this.
More information about the R-help