位于R的Highcharter的两个y轴 [英] Two y Axis in Highcharter in R

查看:235
本文介绍了位于R的Highcharter的两个y轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个折线图,其中包含一个共享两个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://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

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轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆