rcharts highcharts plotLines

时间:2015-06-08 08:04:14

标签: r highcharts rcharts

我在绘图上使用rcharts(highcharts)画一条水平线有点麻烦。我想使用highcharts库中的plotLines来做到这一点。以下是我的代码:

a$yAxis(title='my_Yaxis name', plotLines=list(color='red', value=10, width=2))   

没有plotLines,我的图表显示没有问题。一旦我在plotLines中添加,它就无法正常工作。我不确定rcharts是否支持highcharts中的plotLines?

感谢此处的专家是否可以提供建议。谢谢!

1 个答案:

答案 0 :(得分:0)

你好看这个例子:

library("rCharts")
# Some data
x <- abs(rnorm(10))
# A graph with column
h <- Highcharts$new()
h$chart(type = "column")
h$series(data = x)
h$xAxis(categories = letters[1:10])
# the horizontal line
h$yAxis(title = list(text = "rnorm()"),
        plotLines = list(list(
          value = mean(x),
          color = '#ff0000',
          width = 3,
          zIndex = 4,
          label = list(text = "mean",
                       style = list( color = '#ff0000', fontWeight = 'bold' )
          ))))
h

list()参数中缺少plotLines,需要两个list