Reputation: 4558
I want to set different colors for every point in rPlot
. I expected it was rPlot(V2~V1, data=data, type="point", color=color)
where color
is a vector like c("#6B7BFDFF", "#A7E7BFFF", "#13A0BBFF", ...)
but this doesn't work. So what is the correct grammar? Thank you.
By the way can I find the documentation of rCharts somewhere? I only see examples on the project's website.
Upvotes: 1
Views: 274
Reputation: 6579
Documentation is still a work in progress but closer than ever. If you choose to go with polycharts
(make sure you are aware of paid commercial licensing), then these examples might be helpful. Here is another StackOverflow question on the same topic. I made a quick example below.
library(rCharts)
data(iris)
colnames(iris) <- sapply(colnames(iris), FUN = gsub, pattern = "\\.", replacement = "")
p5 <- rPlot(SepalWidth ~ SepalLength, data = iris, color = "Species", type = "point", height = 400)
# again match polychartjs example exactly to show how we can change axis and legend titles
p5$guides(color = list(scale = "#! function(value){
color_mapping = {versicolor: '#ff2385',setosa:'#229922',virginica:'#2B24D6'}
return color_mapping[value];
} !#"), y = list(title = "sepalWidth"), x = list(title = "sepalLength"))
p5$set(title = "Iris Flowers")
p5
If you choose to use another library, specifying the color will be different, so let me know and I'll be glad to help out.
Upvotes: 2