问题描述
我想制作一个折线图,其中包含一个共享两个y轴的坐标轴,左边一个,右边第二个坐标图 R 。 b
$ b
我发现了很多关于如何实现这个功能的例子,但是我没有设法在R中使用highcharter包来重现。
你n在这种情况下使用 hc_yAxis_multiples
:
highchart()%> ;%
hc_yAxis_multiples(
list(lineWidth = 3),
list(showLastLabel = FALSE,opposite = TRUE)
)%>%
hc_add_series(data = rnorm(10))%>%
hc_add_series(data = rexp(10),type =spline,yAxis = 1)
I would like to make a line chart containing one x axis sharing two y axis, one on the left side and the second one on the right of the plot in R.
I found many examples on how to do this but I don't manage to reproduce it in R with the package "highcharter".
Here are the examples :
http://www.highcharts.com/demo/combo-dual-axes
Here what I have done so far :
g <- highchart()%>%
hc_xAxis(categories = c("2016-01-01","2016-02-01","2016-03-01","2016-04-01","2016-05-01","2016-06-01","2016-07-01","2016-08-01","2016-09-01","2016-10-01"))%>%
hc_yAxis(
list(title = list(text = "Yaxis1")),
list(title = list(text = "Yaxis2"), opposite = TRUE)
)%>%
hc_series(
list(yAxis = 0, data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3), name = "Data1"),
list(yAxis = 1, data = c(8.0, 7.9, 10.5, 15.5, 19.2, 22.5, 28.2, 23.5, 21.3, 14.3), name = "Data2")
)
Does anyone have an idea ?
Thank you !
In the highcharter official website there is a demo with two axis:
http://jkunst.com/highcharter/highcharts.html#highcharts-home-page-demo
You need to use hc_yAxis_multiples
in this case:
highchart() %>%
hc_yAxis_multiples(
list(lineWidth = 3),
list(showLastLabel = FALSE, opposite = TRUE)
) %>%
hc_add_series(data = rnorm(10)) %>%
hc_add_series(data = rexp(10), type = "spline", yAxis = 1)
这篇关于位于R的Highcharter的两个y轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!