在 rCharts 上设置 y 轴的限制

Set the limits for the y-axis on rCharts

如何为 "rCharts" 生成的 "multiBarChart" 图设置限制。例如,我希望 y 轴的值介于 1 和 10 之间。

data<-data.frame(Var=c(1,2,3,4),
                 Fac1=rep(c("A","B"),2),
                 Fac2=rep(c("Blue","Red"),each=2))

require(rCharts)    

n1 <- nPlot(Var~Fac2, group = "Fac1", data = data, type = "multiBarChart")
n1

看看下面的内容 - 利用 forceY 的 NV3D Y 域:

https://github.com/ramnathv/rCharts/issues/361

You can use the chart method and the forceY argument to set the y-axis limits. rCharts tries to stay as close as possible to the API of the original javascript library so that it can take advantage of the full feature set, while still keeping the code base lean.

Here is a minimal example.

library(rCharts)
hair_eye = as.data.frame(HairEyeColor)
p2 <- nPlot(Freq ~ Hair, group = 'Eye', data = subset(hair_eye, Sex == "Female"), type = 'multiBarChart')
p2$chart(color = c('brown', 'blue', '#594c26', 'green'))
p2$chart(forceY = c(0, 100))
p2