r - 我如何告诉 R 在散点图上用颜色填充圆点?

标签 r

我想用颜色填充散点图上的实心圆点。
我试过这个:

>  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=”"

这是行不通的。
我将不胜感激建议/帮助。 :)

最佳答案

颜色名称没有空格,试试 "lightgreen"反而

例子

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

它产生:

enter image description here

关于r - 我如何告诉 R 在散点图上用颜色填充圆点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20454789/

相关文章:

r - 从 R 中每个列表的元素中减去值

r - 添加列以从 R 中的数据框中聚合

r - 查找每个组的最大值并返回另一列

r - 将下一行总结到新列中

r - 将data.frame转换为Zoo

r - glmmADMB 中的新错误? VarCorr 找不到 rdig

r - 使用annotation_custom以编程方式在ggplot上定位图像

R-创建交易对方频率矩阵

r - 数据帧内的数据帧?

从 R 中的 CSV 文件中读取数据帧列表