user3069564 user3069564 - 15 days ago 6
R Question

How do I tell R to fill the circle dots with colour on a scatter plot?

I want to fill the solid circle dots on my scatterplot with colour.
I have tried this:

> plot(dframe1$TV~dframe1$Books)
> xlab="Number of books read per month"
> plot(dframe1$TV~dframe1$Books,
xlab="Number of books read per month")
> plot(dframe1$TV~dframe1$Books,
xlab="Number of books read per month",
ylab="Hours of TV watched per week",
main="Associations between time spent watching TV and reading",
col.main="red",
cex=1.5,
pch=21,
bg=”light green”)
Error: unexpected input in:
"pch=21,bg=”"


It does not work.
I would appreciate advice/help. :)

Answer

Color name is without spaces, try "lightgreen" instead

Example

set.seed(1) # some random data
x <- rnorm(20, 5)
y <- 2 + .78*x + rnorm(20)
plot(y~x, pch=21,  bg="lightgreen")

which produces:

enter image description here