[R] Scatter Plot in R - Help
John Kane
jrkrideau at yahoo.ca
Sat Apr 28 00:18:14 CEST 2007
When I reread it, I think you are right. I read split
the data plot and assumed a backround rather than just
the points .
--- Petr Klasterecky <klaster at karlin.mff.cuni.cz>
wrote:
> If I understand correctly what A. Ezhil asked for,
> polygons won't help
> here. For coloring the individual points check
> ?points and use subsets, e.g.
>
> plot(x,y)
> points(x[x>y-1],y[x>y-1], col="red")
>
> or something similar.
> Petr
>
> John Kane napsal(a):
> > Here is a recent posting by Petr Klasterecky that
> > does not seem to be on the archive yet that may
> help.
> > ----------------------------------------------
> >
> > What do you mean by background? Maybe this is
> enough:
> >
> > plot(seq(-3,3,.01), dnorm(seq(-3,3,.01)),
> type="n",
> > xlab="x",
> > ylab="f(x)", main="Normal density")
> > polygon(x=c(-4,0,0,-4), y=c(-1,-1,.5,.5),
> col="red")
> > polygon(x=c(4,0,0,4), y=c(-1,-1,.5,.5),
> col="blue")
> > lines(seq(-3,3,.01), dnorm(seq(-3,3,.01)),
> type="l",
> > lwd=2)
> >
> > Play a little bit with the polygon margins to get
> what
> > you need. You
> > can
> > even generate them automatically based on your
> data.
> >
> > Petr
> > -----------------------------------------------
> > --- A Ezhil <ezhil02 at yahoo.com> wrote:
> >
> >> Dear All,
> >>
> >> I am using the following commands to do the
> scatter
> >> plot of two vectors, say X and Y.
> >>
> >> plot(X,Y, col="blue")
> >> abline(a=1,b=1, col="red")
> >> abline(a=-1,b=1, col="green")
> >>
> >> I would like to split the scatter plot into 3
> part
> >> with 3 different colors: (i) points lies between
> 2
> >> lines, (ii) points above line 1, and (iii) points
> >> below line 2. I am struggling to do this. I would
> >> greatly appreciate any help in doing this.
> >>
> >> Thanks in advance.
> >>
> >> Kind regards,
> >> Ezhil
> >>
> >> ______________________________________________
> >> 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.
> >
>
> --
> Petr Klasterecky
> Dept. of Probability and Statistics
> Charles University in Prague
> Czech Republic
>
More information about the R-help
mailing list