简体   繁体   English

RBokeh 中的两个 y 轴

[英]Two y Axes in RBokeh

I need to draw a combo chart including two series of bars and two lines using RBokeh.我需要使用 RBokeh 绘制一个包含两个系列的条形图和两条线的组合图。 The syntax for adding bars and lines is quite simple but I cannot add a second y-axis.添加条和线的语法非常简单,但我无法添加第二个 y 轴。 y_axis position can be set to left or right but it does not work when I use them simultaneously. y_axis position 可以设置为左或右,但是当我同时使用它们时它不起作用。

p=figure(width = 600, height = 600) %>%
         ly_points(Data2Chart[c(4,1)], hover = dat) %>%
         ly_lines(Data2Chart[c(4,1)], legend = "X") %>%
         y_axis(position = 'right') %>% 
         y_axis(position = 'left')

I dont really think this is possible and actually also not quite advisible anyways even if it would be (see some discussion about this issue here ).我真的不认为这是可能的,而且实际上也不是很可取,即使它会(参见关于这个问题的一些讨论here )。 I would suggest doing two separate graphs and add them via grid_plot() .我建议做两个单独的图表并通过grid_plot()添加它们。

A really hacky way would be to draw the second axis by yourself via ly_abline(v=...) .一个非常老套的方法是通过ly_abline(v=...)自己绘制第二个轴。 At least in my experience, rBokeh requires a lot of hackiness至少根据我的经验,rBokeh 需要大量hackiness

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM