gpt4 book ai didi

r - R 中 Highcharter 中的两个 y 轴

转载 作者:行者123 更新时间:2023-12-01 07:26:25 25 4
gpt4 key购买 nike

我想制作一个折线图,其中包含一个 x 轴共享两个 y 轴,一个在左侧,第二个在图的右侧 在 R .

我找到了很多关于如何执行此操作的示例,但我无法使用“highcharter”包在 R 中重现它。

以下是示例:

http://jsfiddle.net/gh/get/jquery/1.7.1/highslide-software/highcharts.com/tree/master/samples/highcharts/yaxis/opposite/

http://www.highcharts.com/demo/combo-dual-axes

这是我到目前为止所做的:

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")
)

有没有人有想法?

谢谢 !

最佳答案

在highcharter官网有一个带两个轴的demo:

http://jkunst.com/highcharter/highcharts.html#highcharts-home-page-demo

enter image description here

您需要使用 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)

关于r - R 中 Highcharter 中的两个 y 轴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40084416/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com