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. :)
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 .
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.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With