MultiLine - multiple colors?

Hi all,

Very new to Bokeh (and Python), this may be a pretty simple question, but I haven’t really been able to figure out how to fix it.

When using MultiLine, how can have it use different colors for each line? I’ve tried a few different variations, but I always get the error below.

Code I use (I’m only plotting two lines right now):

glyph = MultiLine(xs=“xs”, ys=“ys”, line_color=[’#8dd3c7’,’#ffffb3’], line_width=2)

``

Error:

ValueError: expected an element of either String, Dict(String, Either(String, Color)) or Color, got [’#8dd3c7’, ‘#ffffb3’]

``

Thanks!

If you use the higher level bokeh.plotting interface, you can pass a list of colors as you have tried:

  p = figure()
  p.multi_line("xs", "ys", line_color=['#8dd3c7','#ffffb3'], line_width=2)

The bokeh.plotting hides some of the work. In particular it takes the list of colors you pass in and puts it in a column data source and wires everything up correctly.

However, you are using the lowest-leve bokeh.models interface. Here, you are setting attributes on the glyph object directly. The color attribute only accepts i) a single color value, or ii) the name of a column in a column data source with the color data. So to use this low level interface, you will need to put the colors in the column data source yourself, and then set "line_color" to be then name of the column with the color data.

Thanks,

Bryan

···

On Jul 7, 2015, at 2:21 PM, [email protected] wrote:

Hi all,

Very new to Bokeh (and Python), this may be a pretty simple question, but I haven't really been able to figure out how to fix it.

When using MultiLine, how can have it use different colors for each line? I've tried a few different variations, but I always get the error below.

Code I use (I'm only plotting two lines right now):

glyph = MultiLine(xs="xs", ys="ys", line_color=['#8dd3c7','#ffffb3'], line_width=2)

Error:
ValueError: expected an element of either String, Dict(String, Either(String, Color)) or Color, got ['#8dd3c7', '#ffffb3']

Thanks!

--
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/e52611b8-55ce-4395-baae-063377902c21%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Thanks, Bryan.

Odd, its working now, but I’m not sure why it wasn’t before.

I am now getting the following error. Is it safe to ignore?:

No handlers could be found for logger “/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/bokeh/validation/check.pyc”

``

On to working with the legend! Thanks!

···

On Tuesday, July 7, 2015 at 3:28:38 PM UTC-4, Bryan Van de ven wrote:

If you use the higher level bokeh.plotting interface, you can pass a list of colors as you have tried:

    p = figure()

    p.multi_line("xs", "ys", line_color=['#8dd3c7','#ffffb3'], line_width=2)

The bokeh.plotting hides some of the work. In particular it takes the list of colors you pass in and puts it in a column data source and wires everything up correctly.

However, you are using the lowest-leve bokeh.models interface. Here, you are setting attributes on the glyph object directly. The color attribute only accepts i) a single color value, or ii) the name of a column in a column data source with the color data. So to use this low level interface, you will need to put the colors in the column data source yourself, and then set “line_color” to be then name of the column with the color data.

Thanks,

Bryan

On Jul 7, 2015, at 2:21 PM, [email protected] wrote:

Hi all,

Very new to Bokeh (and Python), this may be a pretty simple question, but I haven’t really been able to figure out how to fix it.

When using MultiLine, how can have it use different colors for each line? I’ve tried a few different variations, but I always get the error below.

Code I use (I’m only plotting two lines right now):

glyph = MultiLine(xs=“xs”, ys=“ys”, line_color=[‘#8dd3c7’,‘#ffffb3’], line_width=2)

Error:

ValueError: expected an element of either String, Dict(String, Either(String, Color)) or Color, got [‘#8dd3c7’, ‘#ffffb3’]

Thanks!


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/e52611b8-55ce-4395-baae-063377902c21%40continuum.io.

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