# [R] Scatter Plot in R - Help

John Kane jrkrideau at yahoo.ca
Fri Apr 27 20:05:35 CEST 2007

```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.
>
>
> Kind regards,
> Ezhil
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help