Columndatasouce for linear_cmap?

Plotting a heatmap with rect and cant get the fill_color to correspond to the color in the datasource. The data source is shown below. The line_color is picking up the tracerColor from the columndatasource, but how can I get it working for the fill_color?
I need the values that are 0 to be white and the rest to show the color in the from the source data

p.rect(x=“Date”, y = “Zones”, width = 1, height = 1, source = source,

line_color = “tracerColor”, fill_color = linear_cmap(‘Flow’, ["#FFFFFF", “tracerColor”], 0, 1))

Data source looks like this:

ZoneNr Tracer1 Tracer2 Top_m Bottom_m tracerColor Date Zones Flow

0 1 OS-1 WS-1 4738.418 4761.619 red 2012-02-27 00:13:00 WS-1 1.0

1 1 OS-1 WS-1 4738.418 4761.619 red 2012-02-27 01:08:00 WS-1 0.0

2 1 OS-1 WS-1 4738.418 4761.619 red 2012-02-27 03:46:00 WS-1 1.0

3 1 OS-1 WS-1 4738.418 4761.619 red 2012-02-27 06:50:00 WS-1 0.0

4 1 OS-1 WS-1 4738.418 4761.619 red 2012-02-27 11:19:00 WS-1 1.0

``

Any help would be appriciated:)!

A linear color map maps numbers to colors.

tracerColor is a column of strings, it can’t be processed in this way.

Try a factor_cmap which handles categorical mapping - https://bokeh.pydata.org/en/latest/docs/user_guide/categorical.html#colors

···

On Friday, November 9, 2018 at 8:48:25 AM UTC-6, Zana wrote:

Plotting a heatmap with rect and cant get the fill_color to correspond to the color in the datasource. The data source is shown below. The line_color is picking up the tracerColor from the columndatasource, but how can I get it working for the fill_color?
I need the values that are 0 to be white and the rest to show the color in the from the source data

p.rect(x=“Date”, y = “Zones”, width = 1, height = 1, source = source,

line_color = “tracerColor”, fill_color = linear_cmap(‘Flow’, [“#FFFFFF”, “tracerColor”], 0, 1))

Data source looks like this:

ZoneNr Tracer1 Tracer2 Top_m Bottom_m tracerColor Date Zones Flow

0 1 OS-1 WS-1 4738.418 4761.619 red 2012-02-27 00:13:00 WS-1 1.0

1 1 OS-1 WS-1 4738.418 4761.619 red 2012-02-27 01:08:00 WS-1 0.0

2 1 OS-1 WS-1 4738.418 4761.619 red 2012-02-27 03:46:00 WS-1 1.0

3 1 OS-1 WS-1 4738.418 4761.619 red 2012-02-27 06:50:00 WS-1 0.0

4 1 OS-1 WS-1 4738.418 4761.619 red 2012-02-27 11:19:00 WS-1 1.0

``

Any help would be appriciated:)!

Hi Sarah,

I have the same problem with factor_cmap, so that didn’t work. What worked for me was changing the width which was fixed to 1 to the columndatasource value of “Flow”. I changed the fill_color to just color and added the “traceColor” there. That fixed the issue:)

···

On Friday, November 9, 2018 at 3:48:25 PM UTC+1, Zana wrote:

Plotting a heatmap with rect and cant get the fill_color to correspond to the color in the datasource. The data source is shown below. The line_color is picking up the tracerColor from the columndatasource, but how can I get it working for the fill_color?
I need the values that are 0 to be white and the rest to show the color in the from the source data

p.rect(x=“Date”, y = “Zones”, width = 1, height = 1, source = source,

line_color = “tracerColor”, fill_color = linear_cmap(‘Flow’, [“#FFFFFF”, “tracerColor”], 0, 1))

Data source looks like this:

ZoneNr Tracer1 Tracer2 Top_m Bottom_m tracerColor Date Zones Flow

0 1 OS-1 WS-1 4738.418 4761.619 red 2012-02-27 00:13:00 WS-1 1.0

1 1 OS-1 WS-1 4738.418 4761.619 red 2012-02-27 01:08:00 WS-1 0.0

2 1 OS-1 WS-1 4738.418 4761.619 red 2012-02-27 03:46:00 WS-1 1.0

3 1 OS-1 WS-1 4738.418 4761.619 red 2012-02-27 06:50:00 WS-1 0.0

4 1 OS-1 WS-1 4738.418 4761.619 red 2012-02-27 11:19:00 WS-1 1.0

``

Any help would be appriciated:)!