Bokeh server app

Hello all,

I
am new to Bokeh and I am trying to develop a Bokeh server app with sliders in
it. I had modified one of the example codes to my situation and it works
for line and circle plots. Now, I am trying to do the same with ‘quad’ shape
and make it look like a bar graph.

The data for my graph is from
scikit learn prediction models. I would like to move the slider and observe
updated predictions in the graph. The graph loads with the initial predicted
results without any problem. However, once I move the sliders, the graph
disappears (see images below). Could any help me in identifying what could
be wrong? Also is it possible to change the x-axis labels with
string values like ‘Neural network’ in place of 1,2,3?



The callback function for this Boken application is below:

p.quad(top=‘y’, bottom=[0,0,0], left=[1,2,3], right=[1.5, 2.5, 3.5],source=source, color="#B3DE69")

def update_data(attrname, old, new):

p = X.value

t= Y.value

pp = [[p,t]]

yy = [Dtree.predict(pp),Rforest.predict(pp),Etrees.predict(pp)]

source.data = dict(y=yy)

#print(source.data)

for w in [X, Y]:

w.on_change(‘value’, update_data)

``

Thanking you.
Regards,

Sundar.

The problem is that you are mixing columns you created in a column data source, with the automatically created "convenience" columns created by passing list literals to the quad function (i.e., when you do left=[1,2,3]) Then when you do ".data = dict(y=yy)" you erase all those automatically created columns.

There is an open issue to disallow this kind of mixing, because this is so potentially confusing. If you pass in an explicit data source, then you should only use scalar values (left = 0), or refer to columns in the source (left = "mycol").

Short answer, put *all* the data for top, left, bottom, right in your data source, an update all of it on every callback.

For the other question, absolutely. You could use categorical coordinates and axes, or you could create a custom TickFormatter that prints the values you want.

Bryan

···

On Jun 1, 2016, at 2:50 PM, sundaravelpandian Singaravel <[email protected]> wrote:

Hello all,

I am new to Bokeh and I am trying to develop a Bokeh server app with sliders in it. I had modified one of the example codes to my situation and it works for line and circle plots. Now, I am trying to do the same with ‘quad’ shape and make it look like a bar graph.

The data for my graph is from scikit learn prediction models. I would like to move the slider and observe updated predictions in the graph. The graph loads with the initial predicted results without any problem. However, once I move the sliders, the graph disappears (see images below). Could any help me in identifying what could be wrong? Also is it possible to change the x-axis labels with string values like 'Neural network' in place of 1,2,3?

The callback function for this Boken application is below:

p.quad(top='y', bottom=[0,0,0], left=[1,2,3], right=[1.5, 2.5, 3.5],source=source, color="#B3DE69")

def update_data(attrname, old, new):
    p = X.value
    t= Y.value
    pp = [[p,t]]
    yy = [Dtree.predict(pp),Rforest.predict(pp),Etrees.predict(pp)]
    source.data = dict(y=yy)
    #print(source.data)

for w in [X, Y]:
    w.on_change('value', update_data)

Thanking you.
Regards,

Sundar.

--
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/3421b2cb-23f6-4e95-a59a-d437f27de7a4%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Perfect! Now, It works as I want … Thanks Bryan for the quick reply!

Sundar.

···

On 01-Jun-2016, at 10:07 PM, Bryan Van de Ven <[email protected]> wrote:

The problem is that you are mixing columns you created in a column data source, with the automatically created "convenience" columns created by passing list literals to the quad function (i.e., when you do left=[1,2,3]) Then when you do ".data = dict(y=yy)" you erase all those automatically created columns.

There is an open issue to disallow this kind of mixing, because this is so potentially confusing. If you pass in an explicit data source, then you should only use scalar values (left = 0), or refer to columns in the source (left = "mycol").

Short answer, put *all* the data for top, left, bottom, right in your data source, an update all of it on every callback.

For the other question, absolutely. You could use categorical coordinates and axes, or you could create a custom TickFormatter that prints the values you want.

Bryan

On Jun 1, 2016, at 2:50 PM, sundaravelpandian Singaravel <[email protected]> wrote:

Hello all,

I am new to Bokeh and I am trying to develop a Bokeh server app with sliders in it. I had modified one of the example codes to my situation and it works for line and circle plots. Now, I am trying to do the same with ‘quad’ shape and make it look like a bar graph.

The data for my graph is from scikit learn prediction models. I would like to move the slider and observe updated predictions in the graph. The graph loads with the initial predicted results without any problem. However, once I move the sliders, the graph disappears (see images below). Could any help me in identifying what could be wrong? Also is it possible to change the x-axis labels with string values like 'Neural network' in place of 1,2,3?

The callback function for this Boken application is below:

p.quad(top='y', bottom=[0,0,0], left=[1,2,3], right=[1.5, 2.5, 3.5],source=source, color="#B3DE69")

def update_data(attrname, old, new):
   p = X.value
   t= Y.value
   pp = [[p,t]]
   yy = [Dtree.predict(pp),Rforest.predict(pp),Etrees.predict(pp)]
   source.data = dict(y=yy)
   #print(source.data)

for w in [X, Y]:
   w.on_change('value', update_data)

Thanking you.
Regards,

Sundar.

--
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/3421b2cb-23f6-4e95-a59a-d437f27de7a4%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
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/41E6B8B9-B3C2-4902-BF05-ECBED46D1510%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.