This is almost certainly due to read.csv
converting strings to factors
See the difference in this reproducible example
library(rgl)
x<-1:5
y=1:5
z <- 1:5
colors <- c('red','green','blue','orange','purple')
plot3d(x=x,y=y,z=z,col=colors, type = 's')
colorsf <- factor(c('red','green','blue','orange','purple'))
plot3d(x=x,y=y,z=z,col=colorsf, type = 's')
So, either read in color
as a character column using stringsAsFactors=FALSE
or coerce to character using as.character()
or levels(colors)[colors]