Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

r

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. :)

like image 210
user3069564 Avatar asked Dec 08 '13 14:12

user3069564


People also ask

How do I change the color of the dots on a scatter plot in R?

The different color systems available in R have been described in detail here. To change scatter plot color according to the group, you have to specify the name of the data column containing the groups using the argument groupName . Use the argument groupColors , to specify colors by hexadecimal code or by name .

What does R mean on a scatter graph?

The sample correlation coefficient (r) is a measure of the closeness of association of the points in a scatter plot to a linear regression line based on those points, as in the example above for accumulated saving over time.


1 Answers

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

like image 187
Jilber Urbina Avatar answered Oct 04 '22 17:10

Jilber Urbina