[Chicago] Bokeh methods as arguments

Aaron Elmquist elmq0022 at umn.edu
Thu Jun 23 14:58:38 EDT 2016


You might want to look at the getattr so you could writ something like:

    getattr(p, "circle")(x, y, color=color, fill_color="white")

which will pull the circle method off of the p object and pass the

FYI, I'm not super familiar with bokeh, but I would guess there's probably
a config file that would make setting this up easier.

And looks like Brian beat me to the punch.

On Thu, Jun 23, 2016 at 11:43 AM, Robin Fishbein via Chicago <
chicago at python.org> wrote:

> 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
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> https://mail.python.org/mailman/listinfo/chicago
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20160623/928d8822/attachment.html>

More information about the Chicago mailing list