Setting the color for an individual data point

前端 未结 3 577
一整个雨季
一整个雨季 2020-12-05 07:24

How can I set the colour for a single data point in a scatter plot in R?

I am using plot

3条回答
  •  佛祖请我去吃肉
    2020-12-05 08:21

    Use the col= argument which is vectorized so that eg in

     plot(1:5, 1:5, col=1:5)
    

    you get five points in five different colors:

    enter image description here

    You can use the same logic to use just two or three colors among your data points. Understanding indexing is key in languages like R.

提交回复
热议问题