Mario Nuñez
Mario Nuñez

Reputation: 33

Changing Color in nPlot for discreteBarChart

I'm trying to change the color of the bars for a discreteBarChart using nPlot, but the color argument doesn't seem to change anything in the example below:

data(cars) 
speedTableVec<-table(cars$speed) 
speedTable<-data.frame(speedTableVec)
n1<-nPlot(Freq ~ Var1, data=speedTable, type="discreteBarChart", color="blue")
n1

Is there a way to keep the bars consistently one color (i.e. blue)? Thanks.

Upvotes: 3

Views: 883

Answers (1)

Ramnath
Ramnath

Reputation: 55695

Here is a solution. I presume you were looking to use NVD3 and nPlot. See here for the final chart.

data(cars) 
speedTableVec<-table(cars$speed) 
speedTable<-data.frame(speedTableVec)
require(rCharts)
n1 <- nPlot(Freq ~ Var1, data = speedTable, type="discreteBarChart")
n1$chart(color = "#! function(d){ return 'blue'} !#")

Hope this helps.

Upvotes: 3

Related Questions