1

I'm trying to do a plot (from a vector) and coloring based on the values of one of the columns. This is the code that I have.

plot(x = FishVector$Diagonal.Length..cm.,
     y = FishVector$Diagonal.Width..cm., 
     main = "Relación entre largo del pez y el ancho",
     xlab = "Largo del pez(cm)",
     ylab = "Ancho del pez(cm)",
     col = FishVector$Species,
     pch = 20
)

I'm receiving this error msg:

Error in plot.xy(xy, type, ...) : invalid color name 'Bream'

Bream is one of the values for the column Species.

M--
  • 25,431
  • 8
  • 61
  • 93
Daniel
  • 11
  • 1
  • 2
    For base R plots, `col=` needs to be a valid color name. It looks like you are passing in fish names which are not color names. You could convert to factor which would result in numeric values for colors: `col = factor(FishVector$Species)`. That will use the values from `palette()` as colors – MrFlick Jul 06 '21 at 19:52
  • _MrFlick_ is right, you probably learned that method where the respective column is integer which might be what is confusing you now. – jay.sf Jul 06 '21 at 19:58

0 Answers0