[Chicago] Bokeh methods as arguments

Robin Fishbein robinfishbein at yahoo.com
Thu Jun 23 12:43:51 EDT 2016


Is there a way to call methods of the bokeh.plotting.Figure class by passing them as an argument?

I'm trying to write a Bokeh line chart utility that provides pre-selected data point shapes, colors, and line dash styles for a to-be-determined number of data series: a consistent, predefined style that is color-blind-friendly. I can define lists for colors and dashes...
colors = ['blue', 'red', _]
dashes = [[1,0], [2,2], _]
...and pass those values easily because they are keyword arguments, but the shapes are methods of the Figure class.

Here is the behavior I'm trying to copy:

for i, xy in enumerate(xys):
    x, y = map(list, zip(*xy))
    color, dash = colors[i], dashes=[i]
    p.line(x, y, color=color, line_dash=dash)
    if i % 13 == 0:
        p.circle(x, y, line_color=color, fill_color='white')
    elif i % 13 == 1:
        p.triangle(x, y, line_color=color, fill_color='white')
    else:
        pass  # etc.

I'd like to replace the if/elif section with something equivalent to:

    p.myCall(shape_methods[i], x, y, line_color=color, fill_color='white')

Thanks!!
Robin Fishbein


More information about the Chicago mailing list