[R] ggplot2 stat_density2d issue.

Dmitriy Lyubimov dlieu.7 at gmail.com
Thu Apr 19 00:55:31 CEST 2012


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?

Thank you very much.

-Dmitriy



More information about the R-help mailing list