lundi 20 avril 2020

How can i how can i color points of a graph randomly with 3 different colors in R using R basic only

I am working with datasets iris in R. I need to make a graph with axis X=Petal.Length and axis Y=Petal.Width.
It was simple. But I need to colors the points of the graph in 3 different colors randomly. I found the hexadecimal value of each color:

  • orange: #ff8000
  • pink: #ff80c0
  • yellow: #ffff00

Here are the color that I need:

colors needed

I tried to use rgb function but it was without success.
Someone could help me to find how to color the points of the graphs with these 3 colors randomly please?

Here is my code for the the plot, it's just the graph with no specifics colors yet:

plot(iris$Petal.Length, iris$Petal.Width, xlab = "Petal Lenght", ylab = "Petal Width", pch=18)

Thank you for your help




Aucun commentaire:

Enregistrer un commentaire