Re: [R] adding custom details to ggplot subplots

From: hadley wickham <h.wickham_at_gmail.com>
Date: Mon, 14 May 2007 12:56:11 +0200

Hi Antonio,

Again, you can't do it in the current version, but it's pretty easy to do in the new version. The following example comes from the documentation:

# Slopes and intercepts as data
p <- ggplot(mtcars, aes(x = wt, y=mpg), . ~ cyl) + geom_point() df <- data.frame(intercept=25, slope=2)
p + geom_abline(data=df)

# Slopes and intercepts from linear model coefs <- do.call(rbind, by(mtcars, mtcars$cyl, function(df) {

	m <- lm(mpg ~ wt, data=df)
	data.frame(cyl = df$cyl[1], intercept=coef(m)[1], slope=coef(m)[2])
}))
str(coefs)
p + geom_abline(data=coefs)

Hadley

On 5/13/07, Antonio, Fabio Di Narzo <antonio.fabio_at_gmail.com> wrote:
> Hi all.
> Consider the following example from ggplot vignette:
>
> ggpoint( ggplot(tips, .~sex, ae=list(y=tip, x=total_bill)) )
>
> You have one scatterplot per sex. With 'ggabline' I can add one or more
> lines to each subplot at the same time.
> How can I add different lines in each subplot?
> Note that I have 0<knowledge<little of grid graphics.
>
> Antonio.
> --
> Antonio, Fabio Di Narzo
> Ph.D. student at
> Department of Statistical Sciences
> University of Bologna, Italy
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_stat.math.ethz.ch 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.
>



R-help_at_stat.math.ethz.ch 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 Mon 14 May 2007 - 11:01:23 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 Mon 14 May 2007 - 11:31:44 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.