我正在使用bokeh.plotting建设散景。我有两个系列的共享索引,我想绘制两个垂直条。当我使用单个工具条时,一切正常,但是当我添加第二个y范围和第二个工具栏时,它似乎正在影响主要y范围(将vales从0更改为4),而第二个vbar()覆盖第一个。值得赞赏的是,为什么酒吧重叠,而不是并排,为什么第二系列/ yaxis似乎影响第一,即使他们是分开的任何援助,将不胜感激。散焦次y范围影响主要y范围
import pandas as pd
import bokeh.plotting as bp
from bokeh.models import NumeralTickFormatter, HoverTool, Range1d, LinearAxis
df_x_series = ['a','b','c']
fig = bp.figure(title='WIP',x_range=df_x_series,plot_width=1200,plot_height=600,toolbar_location='below',toolbar_sticky=False,tools=['reset','save'],active_scroll=None,active_drag=None,active_tap=None)
fig.title.align= 'center'
fig.extra_y_ranges = {'c_count':Range1d(start=0, end=10)}
fig.add_layout(LinearAxis(y_range_name='c_count'), 'right')
fig.vbar(bottom=0, top=[1,2,3], x=['a','b','c'], color='blue', legend='Amt', width=0.3, alpha=0.5)
fig.vbar(bottom=0, top=[5,7,8], x=['a','b','c'], color='green', legend='Ct', width=0.3, alpha=0.8, y_range_name='c_count')
fig.yaxis[0].formatter = NumeralTickFormatter(format='0.0')
bp.output_file('bar.html')
bp.show(fig)
实现,我的条重叠由于共享索引,但不能与这里所示的例子中偏移它们:https://开头github上。 com/bokeh/bokeh/blob/master/examples/plotting/file/bar_chart.py,因为我使用字符串的分类轴。任何抵消这些想法将不胜感激。也可以通过硬编码修复主要的y轴范围,但希望避免这种情况。 – Alexander