☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Using the bokeh.models API

Community Support
Angelo_Fausti
Angelo_Fausti

Inspired by this post (https://bokeh.github.io/blog/2017/7/5/idiomatic_bokeh/) I am trying to compose glyphs to create a new chart.

I can add a HBar using linear scale in both x and y axis but I need the y axis to be categorical.

What I am doing wrong?

from bokeh.io import curdoc, show, output_notebook

from bokeh.models import Plot, ColumnDataSource, DataRange1d, FactorRange, LinearAxis

from bokeh.models.scales import CategoricalScale

from bokeh.models.glyphs import HBar

output_notebook()

plot = Plot(x_range=DataRange1d(), y_range=FactorRange(), y_scale=CategoricalScale())

source = ColumnDataSource({‘labels’: [‘A’, ‘B’, ‘C’],

‘minimum’: [5, 5, 10],

‘maximum’: [20, 20, 30]})

hbar = HBar(y=‘labels’, left=‘minimum’, right=‘maximum’, height=0.5)

plot.add_glyph(source, hbar)

xaxis = LinearAxis()

plot.add_layout(xaxis, ‘below’)

show(plot)

thanks,

Angelo Fausti

⌁   Link to post
Bryan
Bryan

Hi,

Your FactorRange appears to be unconfigured. It has a "factors" property that needs to list all the categorical factors in the desired order for the axis.

Thanks,

Bryan

···

On Jun 7, 2018, at 13:29, Angelo Fausti <angelofausti@gmail.com> wrote:

Inspired by this post (https://bokeh.github.io/blog/2017/7/5/idiomatic_bokeh/\) I am trying to compose glyphs to create a new chart.

I can add a HBar using linear scale in both x and y axis but I need the y axis to be categorical.

What I am doing wrong?

from bokeh.io import curdoc, show, output_notebook
from bokeh.models import Plot, ColumnDataSource, DataRange1d, FactorRange, LinearAxis
from bokeh.models.scales import CategoricalScale
from bokeh.models.glyphs import HBar
output_notebook()

plot = Plot(x_range=DataRange1d(), y_range=FactorRange(), y_scale=CategoricalScale())

source = ColumnDataSource({'labels': ['A', 'B', 'C'],
                           'minimum': [5, 5, 10],
                           'maximum': [20, 20, 30]})

hbar = HBar(y='labels', left='minimum', right='maximum', height=0.5)
plot.add_glyph(source, hbar)

xaxis = LinearAxis()
plot.add_layout(xaxis, 'below')

show(plot)

thanks,
Angelo Fausti

--
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 bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAD%3DOK5NygU4EVN-Jx-pHewmaTezUS%3DOO55se%3DieUXoigZccy7Q%40mail.gmail.com\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

⌁   Link to post
Angelo_Fausti
Angelo_Fausti

Thanks Brian,

it makes sense now. I have to initialize the FactorRange with the possible factors first, which may not necessarily be the values in the ColumnDataSource.

plot = Plot(x_range=DataRange1d(), y_range=FactorRange(factors=[‘A’, ‘B’, ‘C’]), y_scale=CategoricalScale())

source = ColumnDataSource({‘labels’: [‘A’, ‘B’, ‘C’],

‘values’: [8.0, 11.0, 22.0],

‘stretch’: [5, 5, 10],

‘design’: [10, 10, 15],

‘minimum’: [20, 20, 30]})

hbar = HBar(y=‘labels’, left=‘stretch’, right=‘minimum’, height=0.5)

plot.add_glyph(source, hbar)

xaxis = LinearAxis()

plot.add_layout(xaxis, ‘below’)

show(plot)

···

On Thu, Jun 7, 2018 at 1:35 PM, Bryan Van de ven bryan@bokeh.org wrote:

Hi,

Your FactorRange appears to be unconfigured. It has a “factors” property that needs to list all the categorical factors in the desired order for the axis.

Thanks,

Bryan

On Jun 7, 2018, at 13:29, Angelo Fausti angelofausti@gmail.com wrote:

Inspired by this post (https://bokeh.github.io/blog/2017/7/5/idiomatic_bokeh/) I am trying to compose glyphs to create a new chart.

I can add a HBar using linear scale in both x and y axis but I need the y axis to be categorical.

What I am doing wrong?

from bokeh.io import curdoc, show, output_notebook

from bokeh.models import Plot, ColumnDataSource, DataRange1d, FactorRange, LinearAxis

from bokeh.models.scales import CategoricalScale

from bokeh.models.glyphs import HBar

output_notebook()

plot = Plot(x_range=DataRange1d(), y_range=FactorRange(), y_scale=CategoricalScale())

source = ColumnDataSource({‘labels’: [‘A’, ‘B’, ‘C’],

                       'minimum': [5, 5, 10],
                       'maximum': [20, 20, 30]})

hbar = HBar(y=‘labels’, left=‘minimum’, right=‘maximum’, height=0.5)

plot.add_glyph(source, hbar)

xaxis = LinearAxis()

plot.add_layout(xaxis, ‘below’)

show(plot)

thanks,

Angelo Fausti

–

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 bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAD%3DOK5NygU4EVN-Jx-pHewmaTezUS%3DOO55se%3DieUXoigZccy7Q%40mail.gmail.com.

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

–

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 bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/3DE00562-A8D8-46FC-82E1-8F5545336CA5%40anaconda.com.

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

Angelo Fausti

⌁   Link to post
Angelo_Fausti
Angelo_Fausti

Hi Bryan,

wanted to share this technote that features the Bokeh Models API and the “additive development” approach

https://sqr-022.lsst.io/v/DM-14731/index.html

thanks,

···

On Thu, Jun 7, 2018 at 1:58 PM, Angelo Fausti angelofausti@gmail.com wrote:

Thanks Brian,

it makes sense now. I have to initialize the FactorRange with the possible factors first, which may not necessarily be the values in the ColumnDataSource.

plot = Plot(x_range=DataRange1d(), y_range=FactorRange(factors=[‘A’, ‘B’, ‘C’]), y_scale=CategoricalScale())

source = ColumnDataSource({‘labels’: [‘A’, ‘B’, ‘C’],

‘values’: [8.0, 11.0, 22.0],

‘stretch’: [5, 5, 10],

‘design’: [10, 10, 15],

‘minimum’: [20, 20, 30]})

hbar = HBar(y=‘labels’, left=‘stretch’, right=‘minimum’, height=0.5)

plot.add_glyph(source, hbar)

xaxis = LinearAxis()

plot.add_layout(xaxis, ‘below’)

show(plot)

Angelo Fausti

Angelo Fausti

On Thu, Jun 7, 2018 at 1:35 PM, Bryan Van de ven bryan@bokeh.org wrote:

Hi,

Your FactorRange appears to be unconfigured. It has a “factors” property that needs to list all the categorical factors in the desired order for the axis.

Thanks,

Bryan

On Jun 7, 2018, at 13:29, Angelo Fausti angelofausti@gmail.com wrote:

Inspired by this post (https://bokeh.github.io/blog/2017/7/5/idiomatic_bokeh/) I am trying to compose glyphs to create a new chart.

I can add a HBar using linear scale in both x and y axis but I need the y axis to be categorical.

What I am doing wrong?

from bokeh.io import curdoc, show, output_notebook

from bokeh.models import Plot, ColumnDataSource, DataRange1d, FactorRange, LinearAxis

from bokeh.models.scales import CategoricalScale

from bokeh.models.glyphs import HBar

output_notebook()

plot = Plot(x_range=DataRange1d(), y_range=FactorRange(), y_scale=CategoricalScale())

source = ColumnDataSource({‘labels’: [‘A’, ‘B’, ‘C’],

                       'minimum': [5, 5, 10],
                       'maximum': [20, 20, 30]})

hbar = HBar(y=‘labels’, left=‘minimum’, right=‘maximum’, height=0.5)

plot.add_glyph(source, hbar)

xaxis = LinearAxis()

plot.add_layout(xaxis, ‘below’)

show(plot)

thanks,

Angelo Fausti

–

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 bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAD%3DOK5NygU4EVN-Jx-pHewmaTezUS%3DOO55se%3DieUXoigZccy7Q%40mail.gmail.com.

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

–

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 bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/3DE00562-A8D8-46FC-82E1-8F5545336CA5%40anaconda.com.

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

⌁   Link to post
Bryan
Bryan

Hi Angelo,

That is a nice looking post! We often like to publicize things like this via the BokehPlots twitter account. If you have twitter and would like to post this we'd love to retweet it, or if not we could tweet it out directly if that is ok!

Bryan

···

On Jun 12, 2018, at 08:33, Angelo Fausti <angelofausti@gmail.com> wrote:

Hi Bryan,

wanted to share this technote that features the Bokeh Models API and the "additive development" approach

SQR-022: Creating new charts with the Bokeh Models API

thanks,

Angelo Fausti

On Thu, Jun 7, 2018 at 1:58 PM, Angelo Fausti <angelofausti@gmail.com> wrote:
Thanks Brian,

it makes sense now. I have to initialize the FactorRange with the possible factors first, which may not necessarily be the values in the ColumnDataSource.

plot = Plot(x_range=DataRange1d(), y_range=FactorRange(factors=['A', 'B', 'C']), y_scale=CategoricalScale())

source = ColumnDataSource({'labels': ['A', 'B', 'C'],
                           'values': [8.0, 11.0, 22.0],
                           'stretch': [5, 5, 10],
                           'design': [10, 10, 15],
                           'minimum': [20, 20, 30]})

hbar = HBar(y='labels', left='stretch', right='minimum', height=0.5)
plot.add_glyph(source, hbar)
xaxis = LinearAxis()
plot.add_layout(xaxis, 'below')
show(plot)

Angelo Fausti

On Thu, Jun 7, 2018 at 1:35 PM, Bryan Van de ven <bryan@bokeh.org> wrote:
Hi,

Your FactorRange appears to be unconfigured. It has a "factors" property that needs to list all the categorical factors in the desired order for the axis.

Thanks,

Bryan

> On Jun 7, 2018, at 13:29, Angelo Fausti <angelofausti@gmail.com> wrote:
>
> Inspired by this post (https://bokeh.github.io/blog/2017/7/5/idiomatic_bokeh/\) I am trying to compose glyphs to create a new chart.
>
> I can add a HBar using linear scale in both x and y axis but I need the y axis to be categorical.
>
> What I am doing wrong?
>
> from bokeh.io import curdoc, show, output_notebook
> from bokeh.models import Plot, ColumnDataSource, DataRange1d, FactorRange, LinearAxis
> from bokeh.models.scales import CategoricalScale
> from bokeh.models.glyphs import HBar
> output_notebook()
>
> plot = Plot(x_range=DataRange1d(), y_range=FactorRange(), y_scale=CategoricalScale())
>
> source = ColumnDataSource({'labels': ['A', 'B', 'C'],
> 'minimum': [5, 5, 10],
> 'maximum': [20, 20, 30]})
>
> hbar = HBar(y='labels', left='minimum', right='maximum', height=0.5)
> plot.add_glyph(source, hbar)
>
> xaxis = LinearAxis()
> plot.add_layout(xaxis, 'below')
>
> show(plot)
>
> thanks,
> Angelo Fausti
>
>
> --
> 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 bokeh+unsubscribe@continuum.io.
> To post to this group, send email to bokeh@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAD%3DOK5NygU4EVN-Jx-pHewmaTezUS%3DOO55se%3DieUXoigZccy7Q%40mail.gmail.com\.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
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 bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/3DE00562-A8D8-46FC-82E1-8F5545336CA5%40anaconda.com\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
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 bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAD%3DOK5OTqOQs-HTEh6%2BT7ZEctE8RSoMa-CobaWGOsiqpfFiYZw%40mail.gmail.com\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

⌁   Link to post
Angelo_Fausti
Angelo_Fausti

Sure I can tweet that. It is still in a branch so I’ll wait until its merged. Thanks Bryan.

···

On Tue, Jun 12, 2018 at 10:26 AM, Bryan Van de ven bryan@bokeh.org wrote:

Hi Angelo,

That is a nice looking post! We often like to publicize things like this via the BokehPlots twitter account. If you have twitter and would like to post this we’d love to retweet it, or if not we could tweet it out directly if that is ok!

Bryan

On Jun 12, 2018, at 08:33, Angelo Fausti angelofausti@gmail.com wrote:

Hi Bryan,

wanted to share this technote that features the Bokeh Models API and the “additive development” approach

https://sqr-022.lsst.io/v/DM-14731/index.html

thanks,

Angelo Fausti

On Thu, Jun 7, 2018 at 1:58 PM, Angelo Fausti angelofausti@gmail.com wrote:

Thanks Brian,

it makes sense now. I have to initialize the FactorRange with the possible factors first, which may not necessarily be the values in the ColumnDataSource.

plot = Plot(x_range=DataRange1d(), y_range=FactorRange(factors=[‘A’, ‘B’, ‘C’]), y_scale=CategoricalScale())

source = ColumnDataSource({‘labels’: [‘A’, ‘B’, ‘C’],

                       'values': [8.0, 11.0, 22.0],
                       'stretch': [5, 5, 10],
                       'design': [10, 10, 15],
                       'minimum': [20, 20, 30]})

hbar = HBar(y=‘labels’, left=‘stretch’, right=‘minimum’, height=0.5)

plot.add_glyph(source, hbar)

xaxis = LinearAxis()

plot.add_layout(xaxis, ‘below’)

show(plot)

Angelo Fausti

On Thu, Jun 7, 2018 at 1:35 PM, Bryan Van de ven bryan@bokeh.org wrote:

Hi,

Your FactorRange appears to be unconfigured. It has a “factors” property that needs to list all the categorical factors in the desired order for the axis.

Thanks,

Bryan

On Jun 7, 2018, at 13:29, Angelo Fausti angelofausti@gmail.com wrote:

Inspired by this post (https://bokeh.github.io/blog/2017/7/5/idiomatic_bokeh/) I am trying to compose glyphs to create a new chart.

I can add a HBar using linear scale in both x and y axis but I need the y axis to be categorical.

What I am doing wrong?

from bokeh.io import curdoc, show, output_notebook

from bokeh.models import Plot, ColumnDataSource, DataRange1d, FactorRange, LinearAxis

from bokeh.models.scales import CategoricalScale

from bokeh.models.glyphs import HBar

output_notebook()

plot = Plot(x_range=DataRange1d(), y_range=FactorRange(), y_scale=CategoricalScale())

source = ColumnDataSource({‘labels’: [‘A’, ‘B’, ‘C’],

                       'minimum': [5, 5, 10],
                       'maximum': [20, 20, 30]})

hbar = HBar(y=‘labels’, left=‘minimum’, right=‘maximum’, height=0.5)

plot.add_glyph(source, hbar)

xaxis = LinearAxis()

plot.add_layout(xaxis, ‘below’)

show(plot)

thanks,

Angelo Fausti

–

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 bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAD%3DOK5NygU4EVN-Jx-pHewmaTezUS%3DOO55se%3DieUXoigZccy7Q%40mail.gmail.com.

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

–

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 bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/3DE00562-A8D8-46FC-82E1-8F5545336CA5%40anaconda.com.

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

–

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 bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAD%3DOK5OTqOQs-HTEh6%2BT7ZEctE8RSoMa-CobaWGOsiqpfFiYZw%40mail.gmail.com.

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

–

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 bokeh+unsubscribe@continuum.io.

To post to this group, send email to bokeh@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/EBB66DF9-87EC-438B-B962-E24E14C160F1%40anaconda.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Angelo Fausti

⌁   Link to post

End of archived discussion · Replies are disabled