简体   繁体   English

与BokehJS条形图重叠的酒吧

[英]Overlapping bars with BokehJS bar graph

I'd like to make a plot like the one shown below using BokehJS. 我想使用BokehJS制作如下所示的情节。

Specifically, I have two data series that share x-labels and I want to make a bar graph showing each in a different color (simple enough). 具体来说,我有两个共享x标签的数据系列,我想制作一个条形图,以不同的颜色显示每个(足够简单)。 But style-wise, I would like one bar to be narrower than the other, while they both share the same centers on the x-axis. 但是风格方面,我希望一个条形比另一个条形窄,而它们在x轴上共享相同的中心。 For visibility's sake, the wider bars should be shown "behind" the narrower bars. 为了可见度,较宽的条应显示在较窄条的“后面”。

Moreover, I'd like to make it using purely BokehJS, rather than using the Python interface. 而且,我想使用纯粹的BokehJS,而不是使用Python界面。 I can't find any examples with this styling. 我找不到这种造型的例子。 Any help would be much appreciated! 任何帮助将非常感激!

Oh! 哦! One last thing: ideally, I'd like to be able to update this graph on the fly using javascript. 最后一件事:理想情况下,我希望能够使用javascript动态更新此图表。 So say at the beginning of the exercise, my data is in a javascript variable, but I have alternate data in another javascript variable (with the same structure). 所以说在练习开始时,我的数据是一个javascript变量,但我在另一个javascript变量(具有相同的结构)中有备用数据。 I'd like to be able to update the data and have the graph re-render on the client side. 我希望能够更新数据并在客户端重新呈现图形。 Worst case, I know how to write enough JS to totally tear-down the Bokeh plot and redraw it from scratch when I need to update. 最糟糕的情况是,我知道如何编写足够的JS以完全拆除Bokeh图并在需要更新时从头开始重绘。 But I have to imagine there is a way to simply inject the new numerical data and tell the Bokeh plot to update itself. 但我必须想象有一种方法可以简单地注入新的数值数据并告诉Bokeh图更新自己。 But perhaps I'm too optimistic? 但也许我太乐观了?

条形图与重叠栏

使用bokeh.plotting.vbar并在绘制第二个数据集时将宽度设置为较小的值。

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

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