[R] ggplot2 stat_density2d issue.

David Winsemius dwinsemius at comcast.net
Thu Apr 19 01:31:41 CEST 2012


On Apr 18, 2012, at 6:55 PM, Dmitriy Lyubimov wrote:

> Hello,
>
> I'd be very grateful for help with some ggplot2's stat_density2d  
> issues.
>
> First issue is with data limits. xlim() and ylim() doesn't seem to
> work; instead, estimates (and plotting) seems to be constrained to
> range(x), range(y) no matter what i do. The documentation says i can
> pass in kde2d's parameters to ... but pussing kde2d's "lims" parameter
> achieves nothing. Contrary to the installed package help, the ggplot2
> site reference says that "..." parameters are ignored. So does it or
> does it not use kde2d? it seems not, but if not, how do i set the
> limit?
>
> second question was about bandwidth. I want to override that (ideally,
> similar to "adjust" parameter to stat::density but in case of kde2d,
> "h" parameter would do as well). However, putting h=... doesn't seem
> to have any effect, as as i mentioned before, it doesn't seem that
> stat_density2d uses kde2d contrary to its doc.
>
> Could please somebody clarify what stat the ggplot2:: stat_density2d
> is using now and how do i adjust bandwidth and limits in the current
> version?

https://github.com/hadley/ggplot2/blob/master/R/stat-density-2d.r

(You might consider reading the Posting Guide. I am not pursuing  
further because I do not think it is our responsibility to construct  
test situations.)

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list