[R] Adding additional points to ggplot2

Ista Zahn istazahn at gmail.com
Fri Aug 16 16:48:05 CEST 2013


Hi Chris,

Just add a second geom_point() call and override the y axis mapping.
For example:

library(ggplot2)
ggplot(mtcars, aes(x=hp, y=mpg)) +
  geom_point() +
  geom_point(aes(y=qsec), color="red")

Best,
Ista

On Fri, Aug 16, 2013 at 5:45 AM, Chris89 <chrisege at stud.ntnu.no> wrote:
> Hi!
> I am having a difficulty adding additional points to a plot using ggplot2..
>
> The case is that I want to plot both original and estimated values in the
> same graph, and general I would use
> plot and then lines, but I do not know how to do it with ggplot...
>
> Thanks!
>
> Regards,
> Chris
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Adding-additional-points-to-ggplot2-tp4673928.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.



More information about the R-help mailing list