Re: [R] Question about which kind of plot to use

From: hadley wickham <h.wickham_at_gmail.com>
Date: Thu, 20 Dec 2007 17:39:36 +0000

> Perhaps as long as you're learning a new plotting system, you might also
> check out whether ggplot2 might be an option.
>
> I did a quick and dirty version (which I'm sure Hadley can improve and
> also remind me how to get rid of the legend that shows the "3" that I
> set the size to).
>
> Assuming your data is re-shaped, so it comes out something like mine in
> the artificial example below, then it's a two-liner in ggplot:
>
>
> maxdat.df <- data.frame (
> score1 = rnorm(9, mean = rep(c(10,20,30), each = 3), sd = 1 ) ,
> SD = runif(9) * 2 + .5,
> Group = factor ( rep ( c("V", "W", "X"), each = 3 ) ),
> subGroup = rep( c("B","M","T"), 3) )
>
> maxdat.df
>
> library(ggplot2)
> ggp <- ggplot ( maxdat.df, aes (y = score1, x = interaction(Group ,
> subGroup), min = score1 - SD, max = score1 + SD, size = 3) )
> ggp + geom_pointrange() + coord_flip()

Take the size = 3 out of the aesthetic mappings, and put it directly in geom_pointrange(size = 3) - this way you are setting the size to 3 (mm) rather than asking ggplot to map a variable containing only the value 3 to the size of the points/lines. It's a subtle but important distinction, and I need to figure out how to explain it better.

Hadley

-- 
http://had.co.nz/

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Thu 20 Dec 2007 - 17:44:34 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 22 Dec 2007 - 00:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.