Error upon trying to set nonselection_fill_color="fill_color"

I’m making a scatter plot, and when I set nonselection_fill_color=“fill_color” (which I found here) it throws an error:
Bokeh Error attempted to retrieve property array for nonexistent field 'fill_color'

Here’s some of the relevant code if it helps.

p = figure(plot_width=800,
           tools=[hover, "save,pan,wheel_zoom,box_zoom,reset,tap"],
           x_axis_label=axis_dict[x_axis][0] + (" ($)" if "$" in axis_dict[x_axis] else ""),
           y_axis_label=axis_dict[y_axis][0] + (" ($)" if "$" in axis_dict[y_axis] else ""),
           title=axis_dict[y_axis][0] + ' vs. ' + axis_dict[x_axis][0] + ' (year ' + ', '.join(
               str(year) for year in years) + ')',
           )
color_mapper = CategoricalColorMapper(palette=d3['Category10'][9], factors=sectors[1:10])
p.scatter(x_axis,
          y_axis,
          source=source,
          fill_color={'field': 'sector_revised', 'transform': color_mapper},
          line_color=None,
          legend=field('sector_revised'),
          nonselection_fill_color="fill_color",
          )

```Please let me know what might be the problem, thanks!`

Specifying:

  nonselection_fill_color="fill_color"

means that BokehJS will look for a column in the ColumnDataSource literally named "fill_color" to use to supply the colors to use for nonselected glyphs. But evidently your CDS has no such column. Rather, it appears you are applying a transform to some other column named "sector_revised" for standard fill colors. So you could:

* add a "fill_color" column to your CDS
* pass a similar transform on an existing column to nonselection_fill_color
* pass a fixed value like "red" or "#222222" to nonselection_fill_color

Thank,

Bryan

···

On Mar 12, 2017, at 22:23, [email protected] wrote:

I'm making a scatter plot, and when I set nonselection_fill_color="fill_color" (which I found here) it throws an error:
Bokeh Error attempted to retrieve property array for nonexistent field 'fill_color'

Here's some of the relevant code if it helps.
p = figure(plot_width=800,
           tools=[hover, "save,pan,wheel_zoom,box_zoom,reset,tap"],
           x_axis_label=axis_dict[x_axis][0] + (" (\)" if "" in axis_dict[x_axis] else ""),
           y_axis_label=axis_dict[y_axis][0] + (" (\)" if "" in axis_dict[y_axis] else ""),
           title=axis_dict[y_axis][0] + ' vs. ' + axis_dict[x_axis][0] + ' (year ' + ', '.join(
               str(year) for year in years) + ')',
           )
color_mapper = CategoricalColorMapper(palette=d3['Category10'][9], factors=sectors[1:10])
p.scatter(x_axis,
          y_axis,
          source=source,
          fill_color={'field': 'sector_revised', 'transform': color_mapper},
          line_color=None,
          legend=field('sector_revised'),
          nonselection_fill_color="fill_color",
          )

Please let me know what might be the problem, 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/87786ac2-e767-497a-a22d-c7c4ecd5a81f%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Excellent, you solved my problem! I just set

nonselection_fill_color={'field': 'sector_revised', 'transform': color_mapper}

and it works how I wanted it to.

···

Il giorno domenica 12 marzo 2017 23:32:17 UTC-4, Bryan Van de ven ha scritto:

Specifying:

    nonselection_fill_color="fill_color"

means that BokehJS will look for a column in the ColumnDataSource literally named “fill_color” to use to supply the colors to use for nonselected glyphs. But evidently your CDS has no such column. Rather, it appears you are applying a transform to some other column named “sector_revised” for standard fill colors. So you could:

  • add a “fill_color” column to your CDS

  • pass a similar transform on an existing column to nonselection_fill_color

  • pass a fixed value like “red” or “#222222” to nonselection_fill_color

Thank,

Bryan

On Mar 12, 2017, at 22:23, [email protected] wrote:

I’m making a scatter plot, and when I set nonselection_fill_color=“fill_color” (which I found here) it throws an error:

Bokeh Error attempted to retrieve property array for nonexistent field ‘fill_color’

Here’s some of the relevant code if it helps.
p = figure(plot_width=800,

       tools=[hover, "save,pan,wheel_zoom,box_zoom,reset,tap"],
       x_axis_label=axis_dict[x_axis][0] + (" ($)" if "$" in axis_dict[x_axis] else ""),
       y_axis_label=axis_dict[y_axis][0] + (" ($)" if "$" in axis_dict[y_axis] else ""),
       title=axis_dict[y_axis][0] + ' vs. ' + axis_dict[x_axis][0] + ' (year ' + ', '.join(
           str(year) for year in years) + ')',
       )

color_mapper = CategoricalColorMapper(palette=d3[‘Category10’][9], factors=sectors[1:10])

p.scatter(x_axis,

      y_axis,
      source=source,
      fill_color={'field': 'sector_revised', 'transform': color_mapper},
      line_color=None,
      legend=field('sector_revised'),
      nonselection_fill_color="fill_color",
      )

Please let me know what might be the problem, 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/87786ac2-e767-497a-a22d-c7c4ecd5a81f%40continuum.io.

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