Working on a bar chart where I want to plot multiple series that have a shared index. The issue I’ve ran into is that since the index is categorical I get overlapping bars. In the Bokeh examples this was resolved on the bar_charts.py example here: https://github.com/bokeh/bokeh/blob/master/examples/plotting/file/bar_chart.py by +.02 and -.02 to the index, but I get an error on my chart due to the indexes being strings. You could see something similar if you change the indexes on the first factors here: categorical.py — Bokeh 2.3.3 Documentation to have multiple a, b or other duplicates. I posted my original issue on stack overflow, but still trying to find a good way to offset my vbar with a shared categorical axis of strings. Appreciate any ideas and help.
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=df_x_series, color=‘blue’, legend=‘Amt’, width=0.3, alpha=0.5)
fig.vbar(bottom=0, top=[5,7,8], x=df_x_series, 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)