Change default number of tiles in stat_density2d

289 views
Skip to first unread message

K P

unread,
May 15, 2012, 4:04:32 PM5/15/12
to ggp...@googlegroups.com
I'd like to change the number of tiles or bins. It appears 100 is the default.

I've tried this:

c + stat_density2d(geom="tile", aes(fill = ..density..), bins = .05, contour = FALSE) + xlim(1,10) + ylim(1,10) 
c + stat_density2d(geom="tile", aes(fill = ..density..), binwidth = .05, contour = FALSE) + xlim(1,10) + ylim(1,10) 

But neither changes the plot. Any ideas?

Thanks.

adam.l...@pnc.com

unread,
May 15, 2012, 5:12:03 PM5/15/12
to K P, ggp...@googlegroups.com
Hi Kenton,

It looks like "n" works to indicate the number of bins ...

ggplot(mtcars,aes(carb,gear))+stat_density2d(geom="tile",aes(fill=..density..),n=10,contour=FALSE)


HTH,



From: K P <ken...@kentonpowell.com>
To: ggp...@googlegroups.com
Date: 05/15/2012 04:38 PM
Subject: Change default number of tiles in stat_density2d
Sent by: ggp...@googlegroups.com


--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example:
https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options:
http://groups.google.com/group/ggplot2


The contents of this email are the property of PNC. If it was not addressed to you, you have no legal right to read it. If you think you received it in error, please notify the sender. Do not forward or copy without permission of the sender. This message may contain an advertisement of a product or service and thus may constitute a commercial electronic mail message under US Law. The postal address for PNC is 249 Fifth Avenue, Pittsburgh, PA 15222. If you do not wish to receive any additional advertising or promotional messages from PNC at this e-mail address, click here to unsubscribe. https://pnc.p.delivery.net/m/u/pnc/uni/p.asp
By unsubscribing to this message, you will be unsubscribed from all advertising or promotional messages from PNC. Removing your e-mail address from this mailing list will not affect your subscription to alerts, e-newsletters or account servicing e-mails.


Kenton Powell

unread,
May 15, 2012, 5:33:51 PM5/15/12
to adam.l...@pnc.com, ggp...@googlegroups.com
Yes. Perfect. Thank you. Just out of curiosity: do you know if there is an upper limit? It will do more than than the default 100 (which is great for me) but not 1000.

adam.l...@pnc.com

unread,
May 15, 2012, 5:47:31 PM5/15/12
to Kenton Powell, ggp...@googlegroups.com
I'm not sure. My guess is if there is a limit, it's not self-imposed. I was able to do 1,000 on the cars data set, but not on the diamonds data, because of memory.



From: Kenton Powell <ken...@kentonpowell.com>
To: adam.l...@pnc.com
Cc: ggp...@googlegroups.com
Date: 05/15/2012 05:34 PM
Subject: Re: Change default number of tiles in stat_density2d
Sent by: ggp...@googlegroups.com

Kenton Powell

unread,
May 15, 2012, 6:20:22 PM5/15/12
to adam.l...@pnc.com, ggp...@googlegroups.com
Great. Thanks.
Reply all
Reply to author
Forward
0 new messages