Categorical Bar Chart with overlapping index

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)

Answered on stack overflow.

···

On 9/26/16 5:08 PM, Alex Hagerman
wrote:

    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:
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:
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.

  You received this message because you are subscribed to the Google

Groups “Bokeh Discussion - Public” group.

  To unsubscribe from this group and stop receiving emails from it,

send an email to [email protected].

  To post to this group, send email to [email protected].

  To view this discussion on the web visit [https://groups.google.com/a/continuum.io/d/msgid/bokeh/0eeb4474-1a01-4713-bed7-7593abf826c1%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/0eeb4474-1a01-4713-bed7-7593abf826c1%40continuum.io?utm_medium=email&utm_source=footer).

  For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).


Sarah Bird
Developer, Bokeh

    [
      ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png)
    ](http://continuum.io)

https://github.com/bokeh/bokeh/blob/master/examples/plotting/file/bar_chart.pyhttp://bokeh.pydata.org/en/latest/docs/gallery/categorical.html

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)

http://stackoverflow.com/questions/39712328/bokeh-secondary-y-range-affecting-primary-y-range