我正在使用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