Avoiding dotplots squished to bottom of plot

47 views
Skip to first unread message

Troy S

unread,
Apr 22, 2012, 10:43:53 PM4/22/12
to ggplot2
Thanks for a great product.  I am really enjoying using the new 0.9 features.

In dotplots, how do I avoid the plots squished to the bottom of the plots?  I have tried playing with limits in scale_y_continuous to no avail.

d<-data.frame(ppt=rep(c('a','b'),each=6),
val=c(1,1,1,1,1,1,1,1,2,2,3,3))
print(ggplot(d, aes(x=val))
+geom_dotplot()
+facet_wrap(~ppt)
+scale_y_continuous(limits=c(0,.1)))

In other plots, it appears as if 60 dots are in fact 1. 

Ben Bond-Lamberty

unread,
Apr 23, 2012, 1:35:38 AM4/23/12
to Troy S, ggplot2
> In dotplots, how do I avoid the plots squished to the bottom of the plots?

This is what geom_dotplot is designed to do: stack dots. By increasing
its default "dotsize", you can make the dots take up more of the
vertical plot space, if

Were you thinking of

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

Ben Bond-Lamberty

unread,
Apr 23, 2012, 1:37:01 AM4/23/12
to ggplot2
(...sorry, hit send too soon.)

Were you wanting some different behavior? Then you'll need to use another geom.

Regards,
Ben

Winston Chang

unread,
Apr 23, 2012, 2:48:43 AM4/23/12
to Ben Bond-Lamberty, ggplot2
As Ben noted, one way is to use 'dotsize', which changes the diameter of the dots... You can also use 'stackratio', which changes the vertical spacing between the dots:

d<-data.frame(ppt=rep(c('a','b'),each=6),
  val=c(1,1,1,1,1,1,1,1,2,2,3,3))

ggplot(d, aes(x=val)) +
  geom_dotplot(stackratio=2) +
  facet_wrap(~ppt)

Unfortunately, for geom_dotplot, the numbers on the y axis are pretty much meaningless and I don't think it's possible to change this. If you want the dots to line up with actual count values, you have to tweak the y range by hand.

-Winston

Troy S

unread,
Apr 23, 2012, 2:55:06 AM4/23/12
to Winston Chang, Ben Bond-Lamberty, ggplot2
I will play with these tomorrow but it sounds like I have what I need.  Many thanks.

Troy
Reply all
Reply to author
Forward
0 new messages