Reputation: 41
I can easily specify the data point shape (pch) by adding a column to my data. I am trying to understand why this does not also work for outline color (col) or fill (bg). Note that the shapes do have attributes col and bg. Below is a subset of my data and the code, which works for pch, but not for col or bg. Thanks!
X Y Shape Line Fill
104 87.238 22 "blue" "pink"
693 255.985 21 "gold" "gold"
15 33.069 24 "red" "white"
414 289.072 24 "red" grey
plot(data[,1:2],log="xy",pch=data[,3],col=data[,4],bg=data[,5])
Upvotes: 3
Views: 82
Reputation: 37641
You need
plot(data[,1:2],log="xy",pch=data[,3],
col=as.character(data[,4]),bg=as.character(data[,5]))
Line and Fill were being treated as factors and therefore integers, not the strings that you intended.
Upvotes: 3