returns empty array for bokeh >=3.0

I am currently working on Chartify to realize support for bokeh >=3.0.0.
It is nearly done, but updating bokeh has broken some tests. Right now I am struggling with fixing them.

The main issue seems to be this method that some tests call:

def chart_color_mapper(chart_object):

(see code on GitHub)

For bokeh <= 2.4.3, this method returns a CategoricalColorMapper object
For bokeh >= 3.0.0, is an empty array.

Is there a way to still get the CategoricalColorMapper of a figure like in the older bokeh versions?
In the migration guides and documentation I have found nothing mentioning anything related.

Update: Forgot to mention it, the colors in plotted charts are correct - I have manually checked it. This is really just about automatically testing it.

I am currently working on Chartify to realize support for bokeh >=3.0.0.

That’s actually terrific to hear! We would love to promote/publicize any announcement you make about this (cc @pavithraes @Timo)

A first note, we are encouraging only the use of top level bokeh.models, rather than the submodules, e.g. bokeh.models.CategoricalColorMapper. We have updated all of our docs to avoid using the submodules.

I actually think this might be a bug with select given this MRE:

In [11]: from bokeh.plotting import figure, show
    ...: from bokeh.sampledata.penguins import data
    ...: from bokeh.transform import factor_cmap, factor_mark
    ...: SPECIES = sorted(data.species.unique())
    ...: MARKERS = ['hex', 'circle_x', 'triangle']
    ...: p = figure(title = "Penguin size", background_fill_color="#fafafa")
    ...: p.scatter("flipper_length_mm", "body_mass_g", source=data,
    ...:           legend_group="species", fill_alpha=0.4, size=12,
    ...:           marker=factor_mark('species', MARKERS, SPECIES),
    ...:           color=factor_cmap('species', 'Category10_3', SPECIES))

In [12]: from bokeh.models import CategoricalColorMapper

In [13]:
Out[13]: []

In [17]: p.renderers[0].glyph.fill_color
Out[17]: Field(field='species', transform=CategoricalColorMapper(id='p1049', ...), units=Unspecified)

I have to admit that select is not a feature we really use internally or even advertise that much, so it is maybe not too surprising, though it is definitely under some level of test. This might be specific to glyph’s Fields, which did get some updates around 3.0 and so it could be a matter of needing new tests for this new Field case that did not get added.

Can you make a GitHub Issue with this infomation?

We will try to figure out a workaround in the issue as well.

Thanks for the fast reply!

I will keep that in mind.

Yes I’ll make an issue. :+1:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.