Bokeh bar chart - Is is possible to have conditional formatting

Hi

I am trying to create a vertical bar chart in Bokeh (code below), where the bars are conditionally formatted based on value of the Y axis. So red for negative values, and green for positive values, and a color gradient between the lowest and highest values. I have attached a screenshot of an analogous graph created in Microsoft PowerBI to demonstrated what I am trying do.

Is this possible in Bokeh?

New to Bokeh.

Cheers

Steve

Power BI example with conditional formatting

My current Bokeh chart

from bokeh.plotting import figure, show, output_file

from bokeh.models import Range1d

output_file(‘vbar.html’)

p = figure(width=1200, height=800)

p.vbar(x=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], width=0.5, bottom=0,

top=[-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5] , color=“firebrick”)

p.y_range = Range1d(-7, 7)

show§

Take a look at this example: http://bokeh.pydata.org/en/latest/docs/gallery/texas.html
You can use “transform” argument and pass it a color mapper.

···

On Sunday, February 19, 2017 at 10:15:55 AM UTC+7, [email protected] wrote:

Hi

I am trying to create a vertical bar chart in Bokeh (code below), where the bars are conditionally formatted based on value of the Y axis. So red for negative values, and green for positive values, and a color gradient between the lowest and highest values. I have attached a screenshot of an analogous graph created in Microsoft PowerBI to demonstrated what I am trying do.

Is this possible in Bokeh?

New to Bokeh.

Cheers

Steve

Power BI example with conditional formatting

My current Bokeh chart

from bokeh.plotting import figure, show, output_file

from bokeh.models import Range1d

output_file(‘vbar.html’)

p = figure(width=1200, height=800)

p.vbar(x=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], width=0.5, bottom=0,

top=[-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5] , color=“firebrick”)

p.y_range = Range1d(-7, 7)

show§

What if you want to condition the colors based on the range in y-axis. e.g you want range between 5 and 10 to have red color, from 11 to 20 to have different color and from 20 to 30 to have different color ?

···

On Sunday, February 19, 2017 at 1:08:23 PM UTC+5:30, Eugene Pakhomov wrote:

Take a look at this example: http://bokeh.pydata.org/en/latest/docs/gallery/texas.html
You can use “transform” argument and pass it a color mapper.

On Sunday, February 19, 2017 at 10:15:55 AM UTC+7, [email protected] wrote:

Hi

I am trying to create a vertical bar chart in Bokeh (code below), where the bars are conditionally formatted based on value of the Y axis. So red for negative values, and green for positive values, and a color gradient between the lowest and highest values. I have attached a screenshot of an analogous graph created in Microsoft PowerBI to demonstrated what I am trying do.

Is this possible in Bokeh?

New to Bokeh.

Cheers

Steve

Power BI example with conditional formatting

My current Bokeh chart

from bokeh.plotting import figure, show, output_file

from bokeh.models import Range1d

output_file(‘vbar.html’)

p = figure(width=1200, height=800)

p.vbar(x=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], width=0.5, bottom=0,

top=[-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5] , color=“firebrick”)

p.y_range = Range1d(-7, 7)

show§

Look at LinearColorMapper. And if it doesn’t suit your needs, I bet it’s pretty straightforward to implement a similar mapper with a more intricate mapping scheme.

···

On Tue, Apr 25, 2017 at 5:34 PM, [email protected] wrote:

What if you want to condition the colors based on the range in y-axis. e.g you want range between 5 and 10 to have red color, from 11 to 20 to have different color and from 20 to 30 to have different color ?

On Sunday, February 19, 2017 at 1:08:23 PM UTC+5:30, Eugene Pakhomov wrote:

Take a look at this example: http://bokeh.pydata.org/en/latest/docs/gallery/texas.html
You can use “transform” argument and pass it a color mapper.

On Sunday, February 19, 2017 at 10:15:55 AM UTC+7, [email protected] wrote:

Hi

I am trying to create a vertical bar chart in Bokeh (code below), where the bars are conditionally formatted based on value of the Y axis. So red for negative values, and green for positive values, and a color gradient between the lowest and highest values. I have attached a screenshot of an analogous graph created in Microsoft PowerBI to demonstrated what I am trying do.

Is this possible in Bokeh?

New to Bokeh.

Cheers

Steve

Power BI example with conditional formatting

My current Bokeh chart

from bokeh.plotting import figure, show, output_file

from bokeh.models import Range1d

output_file(‘vbar.html’)

p = figure(width=1200, height=800)

p.vbar(x=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], width=0.5, bottom=0,

top=[-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5] , color=“firebrick”)

p.y_range = Range1d(-7, 7)

show§