Create interactive quad plot

I’m trying to build a quad plot and add interaction, I hope it can grow, but it can’t work, please help me.
在此输入代码…

``

from bokeh.plotting import Figure, output_notebook, show, figure
from bokeh.io import vform
from bokeh.models import CustomJS, ColumnDataSource, Slider

y = 1
df = DataFrame({‘y’: [y]})
source = ColumnDataSource(data=df)

plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])
plot.quad(top=[y], bottom=[0], left=[1],
right=[2], color=“red”, source=source)

# plot.line(‘x’, ‘y’, source=source, line_width=3, line_alpha=0.6)

def callback(source=source):
data = source.get(‘data’)
f = cb_obj.get(‘value’)
y = data[‘y’]
y = f * y

source.trigger('change')

slider = Slider(start=1, end=10, value=1, step=1, title=“power”,
callback=CustomJS.from_py_func(callback))

layout = vform(slider, plot)

show(layout)

At the lowest level all the coordinates for glyphs have to be one of two things:

* a literal number, i.e. y = 10
* a string column name, i.e. y = "price"

As a convenience, when you pass a literal sequence like y=[1,2,3] to a glyph method like Figure.quad, Bokeh will create a new column in the glyph renderers data source to store the data, and give it an internal name that is used as the column name. This is why things are not working for you, the "automatically created" column has some random name, is not named "y", which is the column you are updated. Your quad glyph needs to configured with the *name* of the column in the data source you are explicitly passing in, something like:

  plot.quad(top="y", bottom=0, left=1, right=1, color="red", source=source)

Note also: I have changed all the other properties to literal numbers instead of lists (e.g., left=1 instead of left=[1]) because this kind of mixing automatically created columns, with an explicitly passed in source, an lead to much confusion and error situations, and will *almost certainly be explicitly prohibited in the near future*.

Thanks,

Bryan

···

On Apr 11, 2016, at 9:12 AM, Scott Ming <[email protected]> wrote:

I'm trying to build a quad plot and add interaction, I hope it can grow, but it can't work, please help me.
在此输入代码...
from bokeh.plotting import Figure, output_notebook, show, figure
from bokeh.io import vform
from bokeh.models import CustomJS, ColumnDataSource, Slider

y = 1
df = DataFrame({'y': [y]})
source = ColumnDataSource(data=df)

plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])
plot.quad(top=[y], bottom=[0], left=[1],
    right=[2], color="red", source=source)

# # plot.line('x', 'y', source=source, line_width=3, line_alpha=0.6)

def callback(source=source):
    data = source.get('data')
    f = cb_obj.get('value')
    y = data['y']
    y = f * y
    
    source.trigger('change')

slider = Slider(start=1, end=10, value=1, step=1, title="power",
                callback=CustomJS.from_py_func(callback))

layout = vform(slider, plot)

show(layout)

--
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/99083ed4-d9fb-4709-9172-da2793a33b9f%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi, Bryan.

Thanks for your help, I changed my code after you answer me, but the plot can’t grow too. I don’t know why. I hope you can tell me more error of my code.

This is my new code:

from bokeh.plotting import Figure, output_notebook, show, figure
from [bokeh.io](http://bokeh.io) import vform
from bokeh.models import CustomJS, ColumnDataSource, Slider
import numpy as np
import pandas as pd
from pandas import Series, DataFrame

output_notebook()

y = 1
df = DataFrame({'y': [y]})
source = ColumnDataSource(data=df)

plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])
plot.quad(top='y', bottom=0, left=1, right=1, color="red", source=source)

def callback(source=source):
    data = source.get('data')
    f = cb_obj.get('value')
    y = data['y']
    y = f * y
   
    source.trigger('change')

slider = Slider(start=1, end=10, value=1, step=1, title="power",
                callback=CustomJS.from_py_func(callback))

layout = vform(slider, plot)

show(layout)

Could you give me more code, or some examples of quad plot with interactions.

Thanks,

Scott

···

2016-04-11 23:01 GMT+08:00 Bryan Van de Ven [email protected]:

At the lowest level all the coordinates for glyphs have to be one of two things:

  • a literal number, i.e. y = 10

  • a string column name, i.e. y = “price”

As a convenience, when you pass a literal sequence like y=[1,2,3] to a glyph method like Figure.quad, Bokeh will create a new column in the glyph renderers data source to store the data, and give it an internal name that is used as the column name. This is why things are not working for you, the “automatically created” column has some random name, is not named “y”, which is the column you are updated. Your quad glyph needs to configured with the name of the column in the data source you are explicitly passing in, something like:

    plot.quad(top="y", bottom=0, left=1, right=1, color="red", source=source)

Note also: I have changed all the other properties to literal numbers instead of lists (e.g., left=1 instead of left=[1]) because this kind of mixing automatically created columns, with an explicitly passed in source, an lead to much confusion and error situations, and will almost certainly be explicitly prohibited in the near future.

Thanks,

Bryan

On Apr 11, 2016, at 9:12 AM, Scott Ming [email protected] wrote:

I’m trying to build a quad plot and add interaction, I hope it can grow, but it can’t work, please help me.

在此输入代码…

from bokeh.plotting import Figure, output_notebook, show, figure

from bokeh.io import vform

from bokeh.models import CustomJS, ColumnDataSource, Slider

y = 1

df = DataFrame({‘y’: [y]})

source = ColumnDataSource(data=df)

plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])

plot.quad(top=[y], bottom=[0], left=[1],

right=[2], color="red", source=source)

# plot.line(‘x’, ‘y’, source=source, line_width=3, line_alpha=0.6)

def callback(source=source):

data = source.get('data')
f = cb_obj.get('value')
y = data['y']
y = f * y
source.trigger('change')

slider = Slider(start=1, end=10, value=1, step=1, title=“power”,

            callback=CustomJS.from_py_func(callback))

layout = vform(slider, plot)

show(layout)

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/99083ed4-d9fb-4709-9172-da2793a33b9f%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/80019ED4-52E7-4A45-93EB-C2546982EF61%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Scott,

There are a couple of things amiss in your code:

* left and right were both 1, you had an invisible or nearly invisible zero width quad
* you have to explicitly re-assign to data['y'] in the callback, there are not references like python
* you need to assign a length one array, you were making a longer array each time (think list replication in python: [10] * 3 = [10, 10, 10])
* "f * y" grows without bound, it never gets smaller, I think maybe you just want the top to be slider value?

Here is your code, edited to do roughly what I imagine you want:

from bokeh.plotting import Figure, output_file, show, figure
from bokeh.io import vform
from bokeh.models import CustomJS, ColumnDataSource, Slider
import numpy as np
import pandas as pd
from pandas import Series, DataFrame

output_file("foo.html")

y = 1
df = DataFrame({'y': [y]})
source = ColumnDataSource(data=dict(y=[1]))

plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])
plot.quad(top='y', bottom=0, left=0, right=1, color="red", source=source)

def callback(source=source):
    data = source.get('data')
    f = cb_obj.get('value')
    y = data['y'][0]
    data['y'] = [f]

    source.trigger('change')

slider = Slider(start=1, end=10, value=1, step=1, title="power",
                callback=CustomJS.from_py_func(callback))

layout = vform(slider, plot)

show(layout)

···

On Apr 11, 2016, at 6:47 PM, Scott Ming <[email protected]> wrote:

Hi, Bryan.

Thanks for your help, I changed my code after you answer me, but the plot can't grow too. I don't know why. I hope you can tell me more error of my code.

This is my new code:

from bokeh.plotting import Figure, output_notebook, show, figure
from bokeh.io import vform
from bokeh.models import CustomJS, ColumnDataSource, Slider
import numpy as np
import pandas as pd
from pandas import Series, DataFrame

output_notebook()

y = 1
df = DataFrame({'y': [y]})
source = ColumnDataSource(data=df)

plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])
plot.quad(top='y', bottom=0, left=1, right=1, color="red", source=source)

def callback(source=source):
    data = source.get('data')
    f = cb_obj.get('value')
    y = data['y']
    y = f * y
   
    source.trigger('change')

slider = Slider(start=1, end=10, value=1, step=1, title="power",
                callback=CustomJS.from_py_func(callback))

layout = vform(slider, plot)

show(layout)

Could you give me more code, or some examples of quad plot with interactions.

Thanks,

Scott

2016-04-11 23:01 GMT+08:00 Bryan Van de Ven <[email protected]>:
At the lowest level all the coordinates for glyphs have to be one of two things:

* a literal number, i.e. y = 10
* a string column name, i.e. y = "price"

As a convenience, when you pass a literal sequence like y=[1,2,3] to a glyph method like Figure.quad, Bokeh will create a new column in the glyph renderers data source to store the data, and give it an internal name that is used as the column name. This is why things are not working for you, the "automatically created" column has some random name, is not named "y", which is the column you are updated. Your quad glyph needs to configured with the *name* of the column in the data source you are explicitly passing in, something like:

        plot.quad(top="y", bottom=0, left=1, right=1, color="red", source=source)

Note also: I have changed all the other properties to literal numbers instead of lists (e.g., left=1 instead of left=[1]) because this kind of mixing automatically created columns, with an explicitly passed in source, an lead to much confusion and error situations, and will *almost certainly be explicitly prohibited in the near future*.

Thanks,

Bryan

> On Apr 11, 2016, at 9:12 AM, Scott Ming <[email protected]> wrote:
>
> I'm trying to build a quad plot and add interaction, I hope it can grow, but it can't work, please help me.
> 在此输入代码...
> from bokeh.plotting import Figure, output_notebook, show, figure
> from bokeh.io import vform
> from bokeh.models import CustomJS, ColumnDataSource, Slider
>
> y = 1
> df = DataFrame({'y': [y]})
> source = ColumnDataSource(data=df)
>
> plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])
> plot.quad(top=[y], bottom=[0], left=[1],
> right=[2], color="red", source=source)
>
> # # plot.line('x', 'y', source=source, line_width=3, line_alpha=0.6)
>
> def callback(source=source):
> data = source.get('data')
> f = cb_obj.get('value')
> y = data['y']
> y = f * y
>
> source.trigger('change')
>
> slider = Slider(start=1, end=10, value=1, step=1, title="power",
> callback=CustomJS.from_py_func(callback))
>
> layout = vform(slider, plot)
>
> show(layout)
>
> --
> 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/99083ed4-d9fb-4709-9172-da2793a33b9f%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/80019ED4-52E7-4A45-93EB-C2546982EF61%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 bokeh+unsubsc[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/CAEpx1chYqewu4oyTVVoDyvw%3DJXxsuvEja-SMMEM1rK8QAxw1fA%40mail.gmail.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

HI, Bryan.

Yes, That’s What I want. Thank you very much. How do I hide the x_ticks? Whether the Bar Charts could do it?

16-4-13 08:07

···

2016-04-12 12:54 GMT+08:00 Bryan Van de Ven [email protected]:

Scott,

There are a couple of things amiss in your code:

  • left and right were both 1, you had an invisible or nearly invisible zero width quad

  • you have to explicitly re-assign to data[‘y’] in the callback, there are not references like python

  • you need to assign a length one array, you were making a longer array each time (think list replication in python: [10] * 3 = [10, 10, 10])

  • “f * y” grows without bound, it never gets smaller, I think maybe you just want the top to be slider value?

Here is your code, edited to do roughly what I imagine you want:

from bokeh.plotting import Figure, output_file, show, figure

from bokeh.io import vform

from bokeh.models import CustomJS, ColumnDataSource, Slider

import numpy as np

import pandas as pd

from pandas import Series, DataFrame

output_file(“foo.html”)

y = 1

df = DataFrame({‘y’: [y]})

source = ColumnDataSource(data=dict(y=[1]))

plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])

plot.quad(top=‘y’, bottom=0, left=0, right=1, color=“red”, source=source)

def callback(source=source):

data = source.get('data')

f = cb_obj.get('value')

y = data['y'][0]

data['y'] = [f]



source.trigger('change')

slider = Slider(start=1, end=10, value=1, step=1, title=“power”,

            callback=CustomJS.from_py_func(callback))

layout = vform(slider, plot)

show(layout)

On Apr 11, 2016, at 6:47 PM, Scott Ming [email protected] wrote:

Hi, Bryan.

Thanks for your help, I changed my code after you answer me, but the plot can’t grow too. I don’t know why. I hope you can tell me more error of my code.

This is my new code:

from bokeh.plotting import Figure, output_notebook, show, figure

from bokeh.io import vform

from bokeh.models import CustomJS, ColumnDataSource, Slider

import numpy as np

import pandas as pd

from pandas import Series, DataFrame

output_notebook()

y = 1

df = DataFrame({‘y’: [y]})

source = ColumnDataSource(data=df)

plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])

plot.quad(top=‘y’, bottom=0, left=1, right=1, color=“red”, source=source)

def callback(source=source):

data = source.get('data')
f = cb_obj.get('value')
y = data['y']
y = f * y
source.trigger('change')

slider = Slider(start=1, end=10, value=1, step=1, title=“power”,

            callback=CustomJS.from_py_func(callback))

layout = vform(slider, plot)

show(layout)

Could you give me more code, or some examples of quad plot with interactions.

Thanks,

Scott

2016-04-11 23:01 GMT+08:00 Bryan Van de Ven [email protected]:

At the lowest level all the coordinates for glyphs have to be one of two things:

  • a literal number, i.e. y = 10
  • a string column name, i.e. y = “price”

As a convenience, when you pass a literal sequence like y=[1,2,3] to a glyph method like Figure.quad, Bokeh will create a new column in the glyph renderers data source to store the data, and give it an internal name that is used as the column name. This is why things are not working for you, the “automatically created” column has some random name, is not named “y”, which is the column you are updated. Your quad glyph needs to configured with the name of the column in the data source you are explicitly passing in, something like:

    plot.quad(top="y", bottom=0, left=1, right=1, color="red", source=source)

Note also: I have changed all the other properties to literal numbers instead of lists (e.g., left=1 instead of left=[1]) because this kind of mixing automatically created columns, with an explicitly passed in source, an lead to much confusion and error situations, and will almost certainly be explicitly prohibited in the near future.

Thanks,

Bryan

On Apr 11, 2016, at 9:12 AM, Scott Ming [email protected] wrote:

I’m trying to build a quad plot and add interaction, I hope it can grow, but it can’t work, please help me.

在此输入代码…

from bokeh.plotting import Figure, output_notebook, show, figure

from bokeh.io import vform

from bokeh.models import CustomJS, ColumnDataSource, Slider

y = 1

df = DataFrame({‘y’: [y]})

source = ColumnDataSource(data=df)

plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])

plot.quad(top=[y], bottom=[0], left=[1],

right=[2], color="red", source=source)

# plot.line(‘x’, ‘y’, source=source, line_width=3, line_alpha=0.6)

def callback(source=source):

data = source.get('data')
f = cb_obj.get('value')
y = data['y']
y = f * y
source.trigger('change')

slider = Slider(start=1, end=10, value=1, step=1, title=“power”,

            callback=CustomJS.from_py_func(callback))

layout = vform(slider, plot)

show(layout)

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/99083ed4-d9fb-4709-9172-da2793a33b9f%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/80019ED4-52E7-4A45-93EB-C2546982EF61%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/CAEpx1chYqewu4oyTVVoDyvw%3DJXxsuvEja-SMMEM1rK8QAxw1fA%40mail.gmail.com.

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/634A7F50-2527-4274-8130-89DCFDB346C0%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Scott,

If you want to update the data like this, then you probably want bokeh.plotting and not bokeh.charts. The high-level charts like Bar may do statistical aggregations or grouping before creating the actual plot, which means the data that the callback sees is "one step removed" from the data you start with. In bokeh.plotting the relationship is very simple, each glyph can have properties tied directly to a column of data (and this is the same data a callback would have access to).

Do you want to hide the ticks, or the labels on the ticks? Typically to "hide" things, you can just set the color to None. In any case there is more information about styling tick lines here:

  http://bokeh.pydata.org/en/latest/docs/user_guide/styling.html#tick-lines

Thanks,

Bryan

···

On Apr 12, 2016, at 6:59 PM, Scott Ming <[email protected]> wrote:

HI, Bryan.

Yes, That's What I want. Thank you very much. How do I hide the x_ticks? Whether the Bar Charts could do it?

16-4-13 08:07

2016-04-12 12:54 GMT+08:00 Bryan Van de Ven <[email protected]>:
Scott,

There are a couple of things amiss in your code:

* left and right were both 1, you had an invisible or nearly invisible zero width quad
* you have to explicitly re-assign to data['y'] in the callback, there are not references like python
* you need to assign a length one array, you were making a longer array each time (think list replication in python: [10] * 3 = [10, 10, 10])
* "f * y" grows without bound, it never gets smaller, I think maybe you just want the top to be slider value?

Here is your code, edited to do roughly what I imagine you want:

from bokeh.plotting import Figure, output_file, show, figure
from bokeh.io import vform
from bokeh.models import CustomJS, ColumnDataSource, Slider
import numpy as np
import pandas as pd
from pandas import Series, DataFrame

output_file("foo.html")

y = 1
df = DataFrame({'y': [y]})
source = ColumnDataSource(data=dict(y=[1]))

plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])
plot.quad(top='y', bottom=0, left=0, right=1, color="red", source=source)

def callback(source=source):
    data = source.get('data')
    f = cb_obj.get('value')
    y = data['y'][0]
    data['y'] = [f]

    source.trigger('change')

slider = Slider(start=1, end=10, value=1, step=1, title="power",
                callback=CustomJS.from_py_func(callback))

layout = vform(slider, plot)

show(layout)

> On Apr 11, 2016, at 6:47 PM, Scott Ming <[email protected]> wrote:
>
> Hi, Bryan.
>
> Thanks for your help, I changed my code after you answer me, but the plot can't grow too. I don't know why. I hope you can tell me more error of my code.
>
> This is my new code:
> ```
> from bokeh.plotting import Figure, output_notebook, show, figure
> from bokeh.io import vform
> from bokeh.models import CustomJS, ColumnDataSource, Slider
> import numpy as np
> import pandas as pd
> from pandas import Series, DataFrame
>
> output_notebook()
>
> y = 1
> df = DataFrame({'y': [y]})
> source = ColumnDataSource(data=df)
>
> plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])
> plot.quad(top='y', bottom=0, left=1, right=1, color="red", source=source)
>
>
> def callback(source=source):
> data = source.get('data')
> f = cb_obj.get('value')
> y = data['y']
> y = f * y
>
> source.trigger('change')
>
> slider = Slider(start=1, end=10, value=1, step=1, title="power",
> callback=CustomJS.from_py_func(callback))
>
> layout = vform(slider, plot)
>
> show(layout)
> ```
>
> Could you give me more code, or some examples of quad plot with interactions.
>
> Thanks,
>
> Scott
>
> 2016-04-11 23:01 GMT+08:00 Bryan Van de Ven <[email protected]>:
> At the lowest level all the coordinates for glyphs have to be one of two things:
>
> * a literal number, i.e. y = 10
> * a string column name, i.e. y = "price"
>
> As a convenience, when you pass a literal sequence like y=[1,2,3] to a glyph method like Figure.quad, Bokeh will create a new column in the glyph renderers data source to store the data, and give it an internal name that is used as the column name. This is why things are not working for you, the "automatically created" column has some random name, is not named "y", which is the column you are updated. Your quad glyph needs to configured with the *name* of the column in the data source you are explicitly passing in, something like:
>
> plot.quad(top="y", bottom=0, left=1, right=1, color="red", source=source)
>
> Note also: I have changed all the other properties to literal numbers instead of lists (e.g., left=1 instead of left=[1]) because this kind of mixing automatically created columns, with an explicitly passed in source, an lead to much confusion and error situations, and will *almost certainly be explicitly prohibited in the near future*.
>
> Thanks,
>
> Bryan
>
>
> > On Apr 11, 2016, at 9:12 AM, Scott Ming <[email protected]> wrote:
> >
> > I'm trying to build a quad plot and add interaction, I hope it can grow, but it can't work, please help me.
> > 在此输入代码...
> > from bokeh.plotting import Figure, output_notebook, show, figure
> > from bokeh.io import vform
> > from bokeh.models import CustomJS, ColumnDataSource, Slider
> >
> > y = 1
> > df = DataFrame({'y': [y]})
> > source = ColumnDataSource(data=df)
> >
> > plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])
> > plot.quad(top=[y], bottom=[0], left=[1],
> > right=[2], color="red", source=source)
> >
> > # # plot.line('x', 'y', source=source, line_width=3, line_alpha=0.6)
> >
> > def callback(source=source):
> > data = source.get('data')
> > f = cb_obj.get('value')
> > y = data['y']
> > y = f * y
> >
> > source.trigger('change')
> >
> > slider = Slider(start=1, end=10, value=1, step=1, title="power",
> > callback=CustomJS.from_py_func(callback))
> >
> > layout = vform(slider, plot)
> >
> > show(layout)
> >
> > --
> > 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/99083ed4-d9fb-4709-9172-da2793a33b9f%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/80019ED4-52E7-4A45-93EB-C2546982EF61%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/CAEpx1chYqewu4oyTVVoDyvw%3DJXxsuvEja-SMMEM1rK8QAxw1fA%40mail.gmail.com.
> 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/634A7F50-2527-4274-8130-89DCFDB346C0%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/CAEpx1chwcexvALHaBC72b1R-bsRSCtiT5XH7zCg-V0SgRxWCxg%40mail.gmail.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Ok, thanks

···

2016-04-17 1:52 GMT+08:00 Bryan Van de Ven [email protected]:

Scott,

If you want to update the data like this, then you probably want bokeh.plotting and not bokeh.charts. The high-level charts like Bar may do statistical aggregations or grouping before creating the actual plot, which means the data that the callback sees is “one step removed” from the data you start with. In bokeh.plotting the relationship is very simple, each glyph can have properties tied directly to a column of data (and this is the same data a callback would have access to).

Do you want to hide the ticks, or the labels on the ticks? Typically to “hide” things, you can just set the color to None. In any case there is more information about styling tick lines here:

    [http://bokeh.pydata.org/en/latest/docs/user_guide/styling.html#tick-lines](http://bokeh.pydata.org/en/latest/docs/user_guide/styling.html#tick-lines)

Thanks,

Bryan

On Apr 12, 2016, at 6:59 PM, Scott Ming [email protected] wrote:

HI, Bryan.

Yes, That’s What I want. Thank you very much. How do I hide the x_ticks? Whether the Bar Charts could do it?

16-4-13 08:07

2016-04-12 12:54 GMT+08:00 Bryan Van de Ven [email protected]:

Scott,

There are a couple of things amiss in your code:

  • left and right were both 1, you had an invisible or nearly invisible zero width quad
  • you have to explicitly re-assign to data[‘y’] in the callback, there are not references like python
  • you need to assign a length one array, you were making a longer array each time (think list replication in python: [10] * 3 = [10, 10, 10])
  • “f * y” grows without bound, it never gets smaller, I think maybe you just want the top to be slider value?

Here is your code, edited to do roughly what I imagine you want:

from bokeh.plotting import Figure, output_file, show, figure

from bokeh.io import vform

from bokeh.models import CustomJS, ColumnDataSource, Slider

import numpy as np

import pandas as pd

from pandas import Series, DataFrame

output_file(“foo.html”)

y = 1

df = DataFrame({‘y’: [y]})

source = ColumnDataSource(data=dict(y=[1]))

plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])

plot.quad(top=‘y’, bottom=0, left=0, right=1, color=“red”, source=source)

def callback(source=source):

data = source.get('data')
f = cb_obj.get('value')
y = data['y'][0]
data['y'] = [f]
source.trigger('change')

slider = Slider(start=1, end=10, value=1, step=1, title=“power”,

            callback=CustomJS.from_py_func(callback))

layout = vform(slider, plot)

show(layout)

On Apr 11, 2016, at 6:47 PM, Scott Ming [email protected] wrote:

Hi, Bryan.

Thanks for your help, I changed my code after you answer me, but the plot can’t grow too. I don’t know why. I hope you can tell me more error of my code.

This is my new code:

from bokeh.plotting import Figure, output_notebook, show, figure

from bokeh.io import vform

from bokeh.models import CustomJS, ColumnDataSource, Slider

import numpy as np

import pandas as pd

from pandas import Series, DataFrame

output_notebook()

y = 1

df = DataFrame({‘y’: [y]})

source = ColumnDataSource(data=df)

plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])

plot.quad(top=‘y’, bottom=0, left=1, right=1, color=“red”, source=source)

def callback(source=source):

data = source.get('data')
f = cb_obj.get('value')
y = data['y']
y = f * y
source.trigger('change')

slider = Slider(start=1, end=10, value=1, step=1, title=“power”,

            callback=CustomJS.from_py_func(callback))

layout = vform(slider, plot)

show(layout)

Could you give me more code, or some examples of quad plot with interactions.

Thanks,

Scott

2016-04-11 23:01 GMT+08:00 Bryan Van de Ven [email protected]:

At the lowest level all the coordinates for glyphs have to be one of two things:

  • a literal number, i.e. y = 10
  • a string column name, i.e. y = “price”

As a convenience, when you pass a literal sequence like y=[1,2,3] to a glyph method like Figure.quad, Bokeh will create a new column in the glyph renderers data source to store the data, and give it an internal name that is used as the column name. This is why things are not working for you, the “automatically created” column has some random name, is not named “y”, which is the column you are updated. Your quad glyph needs to configured with the name of the column in the data source you are explicitly passing in, something like:

    plot.quad(top="y", bottom=0, left=1, right=1, color="red", source=source)

Note also: I have changed all the other properties to literal numbers instead of lists (e.g., left=1 instead of left=[1]) because this kind of mixing automatically created columns, with an explicitly passed in source, an lead to much confusion and error situations, and will almost certainly be explicitly prohibited in the near future.

Thanks,

Bryan

On Apr 11, 2016, at 9:12 AM, Scott Ming [email protected] wrote:

I’m trying to build a quad plot and add interaction, I hope it can grow, but it can’t work, please help me.

在此输入代码…

from bokeh.plotting import Figure, output_notebook, show, figure

from bokeh.io import vform

from bokeh.models import CustomJS, ColumnDataSource, Slider

y = 1

df = DataFrame({‘y’: [y]})

source = ColumnDataSource(data=df)

plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])

plot.quad(top=[y], bottom=[0], left=[1],

right=[2], color="red", source=source)

# plot.line(‘x’, ‘y’, source=source, line_width=3, line_alpha=0.6)

def callback(source=source):

data = source.get('data')
f = cb_obj.get('value')
y = data['y']
y = f * y
source.trigger('change')

slider = Slider(start=1, end=10, value=1, step=1, title=“power”,

            callback=CustomJS.from_py_func(callback))

layout = vform(slider, plot)

show(layout)

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/99083ed4-d9fb-4709-9172-da2793a33b9f%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/80019ED4-52E7-4A45-93EB-C2546982EF61%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/CAEpx1chYqewu4oyTVVoDyvw%3DJXxsuvEja-SMMEM1rK8QAxw1fA%40mail.gmail.com.

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/634A7F50-2527-4274-8130-89DCFDB346C0%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/CAEpx1chwcexvALHaBC72b1R-bsRSCtiT5XH7zCg-V0SgRxWCxg%40mail.gmail.com.

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/3547B279-68AD-4132-8852-15A417ED6A5B%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi, Bryan, I want to hide the bottom numbers.

···

2016-04-17 13:43 GMT+08:00 Scott Ming [email protected]:

Ok, thanks

2016-04-17 1:52 GMT+08:00 Bryan Van de Ven [email protected]:

Scott,

If you want to update the data like this, then you probably want bokeh.plotting and not bokeh.charts. The high-level charts like Bar may do statistical aggregations or grouping before creating the actual plot, which means the data that the callback sees is “one step removed” from the data you start with. In bokeh.plotting the relationship is very simple, each glyph can have properties tied directly to a column of data (and this is the same data a callback would have access to).

Do you want to hide the ticks, or the labels on the ticks? Typically to “hide” things, you can just set the color to None. In any case there is more information about styling tick lines here:

    [http://bokeh.pydata.org/en/latest/docs/user_guide/styling.html#tick-lines](http://bokeh.pydata.org/en/latest/docs/user_guide/styling.html#tick-lines)

Thanks,

Bryan

On Apr 12, 2016, at 6:59 PM, Scott Ming [email protected] wrote:

HI, Bryan.

Yes, That’s What I want. Thank you very much. How do I hide the x_ticks? Whether the Bar Charts could do it?

16-4-13 08:07

2016-04-12 12:54 GMT+08:00 Bryan Van de Ven [email protected]:

Scott,

There are a couple of things amiss in your code:

  • left and right were both 1, you had an invisible or nearly invisible zero width quad
  • you have to explicitly re-assign to data[‘y’] in the callback, there are not references like python
  • you need to assign a length one array, you were making a longer array each time (think list replication in python: [10] * 3 = [10, 10, 10])
  • “f * y” grows without bound, it never gets smaller, I think maybe you just want the top to be slider value?

Here is your code, edited to do roughly what I imagine you want:

from bokeh.plotting import Figure, output_file, show, figure

from bokeh.io import vform

from bokeh.models import CustomJS, ColumnDataSource, Slider

import numpy as np

import pandas as pd

from pandas import Series, DataFrame

output_file(“foo.html”)

y = 1

df = DataFrame({‘y’: [y]})

source = ColumnDataSource(data=dict(y=[1]))

plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])

plot.quad(top=‘y’, bottom=0, left=0, right=1, color=“red”, source=source)

def callback(source=source):

data = source.get('data')
f = cb_obj.get('value')
y = data['y'][0]
data['y'] = [f]
source.trigger('change')

slider = Slider(start=1, end=10, value=1, step=1, title=“power”,

            callback=CustomJS.from_py_func(callback))

layout = vform(slider, plot)

show(layout)

On Apr 11, 2016, at 6:47 PM, Scott Ming [email protected] wrote:

Hi, Bryan.

Thanks for your help, I changed my code after you answer me, but the plot can’t grow too. I don’t know why. I hope you can tell me more error of my code.

This is my new code:

from bokeh.plotting import Figure, output_notebook, show, figure

from bokeh.io import vform

from bokeh.models import CustomJS, ColumnDataSource, Slider

import numpy as np

import pandas as pd

from pandas import Series, DataFrame

output_notebook()

y = 1

df = DataFrame({‘y’: [y]})

source = ColumnDataSource(data=df)

plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])

plot.quad(top=‘y’, bottom=0, left=1, right=1, color=“red”, source=source)

def callback(source=source):

data = source.get('data')
f = cb_obj.get('value')
y = data['y']
y = f * y
source.trigger('change')

slider = Slider(start=1, end=10, value=1, step=1, title=“power”,

            callback=CustomJS.from_py_func(callback))

layout = vform(slider, plot)

show(layout)

Could you give me more code, or some examples of quad plot with interactions.

Thanks,

Scott

2016-04-11 23:01 GMT+08:00 Bryan Van de Ven [email protected]:

At the lowest level all the coordinates for glyphs have to be one of two things:

  • a literal number, i.e. y = 10
  • a string column name, i.e. y = “price”

As a convenience, when you pass a literal sequence like y=[1,2,3] to a glyph method like Figure.quad, Bokeh will create a new column in the glyph renderers data source to store the data, and give it an internal name that is used as the column name. This is why things are not working for you, the “automatically created” column has some random name, is not named “y”, which is the column you are updated. Your quad glyph needs to configured with the name of the column in the data source you are explicitly passing in, something like:

    plot.quad(top="y", bottom=0, left=1, right=1, color="red", source=source)

Note also: I have changed all the other properties to literal numbers instead of lists (e.g., left=1 instead of left=[1]) because this kind of mixing automatically created columns, with an explicitly passed in source, an lead to much confusion and error situations, and will almost certainly be explicitly prohibited in the near future.

Thanks,

Bryan

On Apr 11, 2016, at 9:12 AM, Scott Ming [email protected] wrote:

I’m trying to build a quad plot and add interaction, I hope it can grow, but it can’t work, please help me.

在此输入代码…

from bokeh.plotting import Figure, output_notebook, show, figure

from bokeh.io import vform

from bokeh.models import CustomJS, ColumnDataSource, Slider

y = 1

df = DataFrame({‘y’: [y]})

source = ColumnDataSource(data=df)

plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])

plot.quad(top=[y], bottom=[0], left=[1],

right=[2], color="red", source=source)

# plot.line(‘x’, ‘y’, source=source, line_width=3, line_alpha=0.6)

def callback(source=source):

data = source.get('data')
f = cb_obj.get('value')
y = data['y']
y = f * y
source.trigger('change')

slider = Slider(start=1, end=10, value=1, step=1, title=“power”,

            callback=CustomJS.from_py_func(callback))

layout = vform(slider, plot)

show(layout)

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/99083ed4-d9fb-4709-9172-da2793a33b9f%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/80019ED4-52E7-4A45-93EB-C2546982EF61%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/CAEpx1chYqewu4oyTVVoDyvw%3DJXxsuvEja-SMMEM1rK8QAxw1fA%40mail.gmail.com.

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/634A7F50-2527-4274-8130-89DCFDB346C0%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/CAEpx1chwcexvALHaBC72b1R-bsRSCtiT5XH7zCg-V0SgRxWCxg%40mail.gmail.com.

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/3547B279-68AD-4132-8852-15A417ED6A5B%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Scott,

Sorry I don't quite understand, do you mean the x-axis?

Bryan

···

On Apr 21, 2016, at 9:32 AM, Scott Ming <[email protected]> wrote:

Hi, Bryan, I want to hide the bottom numbers.

2016-04-17 13:43 GMT+08:00 Scott Ming <[email protected]>:
Ok, thanks

2016-04-17 1:52 GMT+08:00 Bryan Van de Ven <[email protected]>:
Scott,

If you want to update the data like this, then you probably want bokeh.plotting and not bokeh.charts. The high-level charts like Bar may do statistical aggregations or grouping before creating the actual plot, which means the data that the callback sees is "one step removed" from the data you start with. In bokeh.plotting the relationship is very simple, each glyph can have properties tied directly to a column of data (and this is the same data a callback would have access to).

Do you want to hide the ticks, or the labels on the ticks? Typically to "hide" things, you can just set the color to None. In any case there is more information about styling tick lines here:

        http://bokeh.pydata.org/en/latest/docs/user_guide/styling.html#tick-lines

Thanks,

Bryan

> On Apr 12, 2016, at 6:59 PM, Scott Ming <[email protected]> wrote:
>
> HI, Bryan.
>
> Yes, That's What I want. Thank you very much. How do I hide the x_ticks? Whether the Bar Charts could do it?
>
> 16-4-13 08:07
>
> 2016-04-12 12:54 GMT+08:00 Bryan Van de Ven <[email protected]>:
> Scott,
>
> There are a couple of things amiss in your code:
>
> * left and right were both 1, you had an invisible or nearly invisible zero width quad
> * you have to explicitly re-assign to data['y'] in the callback, there are not references like python
> * you need to assign a length one array, you were making a longer array each time (think list replication in python: [10] * 3 = [10, 10, 10])
> * "f * y" grows without bound, it never gets smaller, I think maybe you just want the top to be slider value?
>
> Here is your code, edited to do roughly what I imagine you want:
>
>
> from bokeh.plotting import Figure, output_file, show, figure
> from bokeh.io import vform
> from bokeh.models import CustomJS, ColumnDataSource, Slider
> import numpy as np
> import pandas as pd
> from pandas import Series, DataFrame
>
> output_file("foo.html")
>
> y = 1
> df = DataFrame({'y': [y]})
> source = ColumnDataSource(data=dict(y=[1]))
>
> plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])
> plot.quad(top='y', bottom=0, left=0, right=1, color="red", source=source)
>
> def callback(source=source):
> data = source.get('data')
> f = cb_obj.get('value')
> y = data['y'][0]
> data['y'] = [f]
>
> source.trigger('change')
>
> slider = Slider(start=1, end=10, value=1, step=1, title="power",
> callback=CustomJS.from_py_func(callback))
>
> layout = vform(slider, plot)
>
> show(layout)
>
>
>
>
>
> > On Apr 11, 2016, at 6:47 PM, Scott Ming <[email protected]> wrote:
> >
> > Hi, Bryan.
> >
> > Thanks for your help, I changed my code after you answer me, but the plot can't grow too. I don't know why. I hope you can tell me more error of my code.
> >
> > This is my new code:
> > ```
> > from bokeh.plotting import Figure, output_notebook, show, figure
> > from bokeh.io import vform
> > from bokeh.models import CustomJS, ColumnDataSource, Slider
> > import numpy as np
> > import pandas as pd
> > from pandas import Series, DataFrame
> >
> > output_notebook()
> >
> > y = 1
> > df = DataFrame({'y': [y]})
> > source = ColumnDataSource(data=df)
> >
> > plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])
> > plot.quad(top='y', bottom=0, left=1, right=1, color="red", source=source)
> >
> >
> > def callback(source=source):
> > data = source.get('data')
> > f = cb_obj.get('value')
> > y = data['y']
> > y = f * y
> >
> > source.trigger('change')
> >
> > slider = Slider(start=1, end=10, value=1, step=1, title="power",
> > callback=CustomJS.from_py_func(callback))
> >
> > layout = vform(slider, plot)
> >
> > show(layout)
> > ```
> >
> > Could you give me more code, or some examples of quad plot with interactions.
> >
> > Thanks,
> >
> > Scott
> >
> > 2016-04-11 23:01 GMT+08:00 Bryan Van de Ven <[email protected]>:
> > At the lowest level all the coordinates for glyphs have to be one of two things:
> >
> > * a literal number, i.e. y = 10
> > * a string column name, i.e. y = "price"
> >
> > As a convenience, when you pass a literal sequence like y=[1,2,3] to a glyph method like Figure.quad, Bokeh will create a new column in the glyph renderers data source to store the data, and give it an internal name that is used as the column name. This is why things are not working for you, the "automatically created" column has some random name, is not named "y", which is the column you are updated. Your quad glyph needs to configured with the *name* of the column in the data source you are explicitly passing in, something like:
> >
> > plot.quad(top="y", bottom=0, left=1, right=1, color="red", source=source)
> >
> > Note also: I have changed all the other properties to literal numbers instead of lists (e.g., left=1 instead of left=[1]) because this kind of mixing automatically created columns, with an explicitly passed in source, an lead to much confusion and error situations, and will *almost certainly be explicitly prohibited in the near future*.
> >
> > Thanks,
> >
> > Bryan
> >
> >
> > > On Apr 11, 2016, at 9:12 AM, Scott Ming <[email protected]> wrote:
> > >
> > > I'm trying to build a quad plot and add interaction, I hope it can grow, but it can't work, please help me.
> > > 在此输入代码...
> > > from bokeh.plotting import Figure, output_notebook, show, figure
> > > from bokeh.io import vform
> > > from bokeh.models import CustomJS, ColumnDataSource, Slider
> > >
> > > y = 1
> > > df = DataFrame({'y': [y]})
> > > source = ColumnDataSource(data=df)
> > >
> > > plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])
> > > plot.quad(top=[y], bottom=[0], left=[1],
> > > right=[2], color="red", source=source)
> > >
> > > # # plot.line('x', 'y', source=source, line_width=3, line_alpha=0.6)
> > >
> > > def callback(source=source):
> > > data = source.get('data')
> > > f = cb_obj.get('value')
> > > y = data['y']
> > > y = f * y
> > >
> > > source.trigger('change')
> > >
> > > slider = Slider(start=1, end=10, value=1, step=1, title="power",
> > > callback=CustomJS.from_py_func(callback))
> > >
> > > layout = vform(slider, plot)
> > >
> > > show(layout)
> > >
> > > --
> > > 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/99083ed4-d9fb-4709-9172-da2793a33b9f%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/80019ED4-52E7-4A45-93EB-C2546982EF61%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/CAEpx1chYqewu4oyTVVoDyvw%3DJXxsuvEja-SMMEM1rK8QAxw1fA%40mail.gmail.com.
> > 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/634A7F50-2527-4274-8130-89DCFDB346C0%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/CAEpx1chwcexvALHaBC72b1R-bsRSCtiT5XH7zCg-V0SgRxWCxg%40mail.gmail.com.
> 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/3547B279-68AD-4132-8852-15A417ED6A5B%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/CAEpx1ciexJuYy4aVakW5drLkJNb7JgWqDWC-%2BDu6Kyk0k%2Bv7Lg%40mail.gmail.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi, Bryan.

Yes, I want to change the numbers to words of x-axis.

Thanks

16-4-24 22:19

···

2016-04-21 23:18 GMT+08:00 Bryan Van de Ven [email protected]:

Scott,

Sorry I don’t quite understand, do you mean the x-axis?

Bryan

On Apr 21, 2016, at 9:32 AM, Scott Ming [email protected] wrote:

Hi, Bryan, I want to hide the bottom numbers.

2016-04-17 13:43 GMT+08:00 Scott Ming [email protected]:

Ok, thanks

2016-04-17 1:52 GMT+08:00 Bryan Van de Ven [email protected]:

Scott,

If you want to update the data like this, then you probably want bokeh.plotting and not bokeh.charts. The high-level charts like Bar may do statistical aggregations or grouping before creating the actual plot, which means the data that the callback sees is “one step removed” from the data you start with. In bokeh.plotting the relationship is very simple, each glyph can have properties tied directly to a column of data (and this is the same data a callback would have access to).

Do you want to hide the ticks, or the labels on the ticks? Typically to “hide” things, you can just set the color to None. In any case there is more information about styling tick lines here:

    [http://bokeh.pydata.org/en/latest/docs/user_guide/styling.html#tick-lines](http://bokeh.pydata.org/en/latest/docs/user_guide/styling.html#tick-lines)

Thanks,

Bryan

On Apr 12, 2016, at 6:59 PM, Scott Ming [email protected] wrote:

HI, Bryan.

Yes, That’s What I want. Thank you very much. How do I hide the x_ticks? Whether the Bar Charts could do it?

16-4-13 08:07

2016-04-12 12:54 GMT+08:00 Bryan Van de Ven [email protected]:

Scott,

There are a couple of things amiss in your code:

  • left and right were both 1, you had an invisible or nearly invisible zero width quad
  • you have to explicitly re-assign to data[‘y’] in the callback, there are not references like python
  • you need to assign a length one array, you were making a longer array each time (think list replication in python: [10] * 3 = [10, 10, 10])
  • “f * y” grows without bound, it never gets smaller, I think maybe you just want the top to be slider value?

Here is your code, edited to do roughly what I imagine you want:

from bokeh.plotting import Figure, output_file, show, figure

from bokeh.io import vform

from bokeh.models import CustomJS, ColumnDataSource, Slider

import numpy as np

import pandas as pd

from pandas import Series, DataFrame

output_file(“foo.html”)

y = 1

df = DataFrame({‘y’: [y]})

source = ColumnDataSource(data=dict(y=[1]))

plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])

plot.quad(top=‘y’, bottom=0, left=0, right=1, color=“red”, source=source)

def callback(source=source):

data = source.get('data')
f = cb_obj.get('value')
y = data['y'][0]
data['y'] = [f]
source.trigger('change')

slider = Slider(start=1, end=10, value=1, step=1, title=“power”,

            callback=CustomJS.from_py_func(callback))

layout = vform(slider, plot)

show(layout)

On Apr 11, 2016, at 6:47 PM, Scott Ming [email protected] wrote:

Hi, Bryan.

Thanks for your help, I changed my code after you answer me, but the plot can’t grow too. I don’t know why. I hope you can tell me more error of my code.

This is my new code:

from bokeh.plotting import Figure, output_notebook, show, figure

from bokeh.io import vform

from bokeh.models import CustomJS, ColumnDataSource, Slider

import numpy as np

import pandas as pd

from pandas import Series, DataFrame

output_notebook()

y = 1

df = DataFrame({‘y’: [y]})

source = ColumnDataSource(data=df)

plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])

plot.quad(top=‘y’, bottom=0, left=1, right=1, color=“red”, source=source)

def callback(source=source):

data = source.get('data')
f = cb_obj.get('value')
y = data['y']
y = f * y
source.trigger('change')

slider = Slider(start=1, end=10, value=1, step=1, title=“power”,

            callback=CustomJS.from_py_func(callback))

layout = vform(slider, plot)

show(layout)

Could you give me more code, or some examples of quad plot with interactions.

Thanks,

Scott

2016-04-11 23:01 GMT+08:00 Bryan Van de Ven [email protected]:

At the lowest level all the coordinates for glyphs have to be one of two things:

  • a literal number, i.e. y = 10
  • a string column name, i.e. y = “price”

As a convenience, when you pass a literal sequence like y=[1,2,3] to a glyph method like Figure.quad, Bokeh will create a new column in the glyph renderers data source to store the data, and give it an internal name that is used as the column name. This is why things are not working for you, the “automatically created” column has some random name, is not named “y”, which is the column you are updated. Your quad glyph needs to configured with the name of the column in the data source you are explicitly passing in, something like:

    plot.quad(top="y", bottom=0, left=1, right=1, color="red", source=source)

Note also: I have changed all the other properties to literal numbers instead of lists (e.g., left=1 instead of left=[1]) because this kind of mixing automatically created columns, with an explicitly passed in source, an lead to much confusion and error situations, and will almost certainly be explicitly prohibited in the near future.

Thanks,

Bryan

On Apr 11, 2016, at 9:12 AM, Scott Ming [email protected] wrote:

I’m trying to build a quad plot and add interaction, I hope it can grow, but it can’t work, please help me.

在此输入代码…

from bokeh.plotting import Figure, output_notebook, show, figure

from bokeh.io import vform

from bokeh.models import CustomJS, ColumnDataSource, Slider

y = 1

df = DataFrame({‘y’: [y]})

source = ColumnDataSource(data=df)

plot = figure(plot_width=400, plot_height=400, x_range=[0, 5], y_range=[0, 20])

plot.quad(top=[y], bottom=[0], left=[1],

right=[2], color="red", source=source)

# plot.line(‘x’, ‘y’, source=source, line_width=3, line_alpha=0.6)

def callback(source=source):

data = source.get('data')
f = cb_obj.get('value')
y = data['y']
y = f * y
source.trigger('change')

slider = Slider(start=1, end=10, value=1, step=1, title=“power”,

            callback=CustomJS.from_py_func(callback))

layout = vform(slider, plot)

show(layout)

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/99083ed4-d9fb-4709-9172-da2793a33b9f%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/80019ED4-52E7-4A45-93EB-C2546982EF61%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/CAEpx1chYqewu4oyTVVoDyvw%3DJXxsuvEja-SMMEM1rK8QAxw1fA%40mail.gmail.com.

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/634A7F50-2527-4274-8130-89DCFDB346C0%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/CAEpx1chwcexvALHaBC72b1R-bsRSCtiT5XH7zCg-V0SgRxWCxg%40mail.gmail.com.

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/3547B279-68AD-4132-8852-15A417ED6A5B%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/CAEpx1ciexJuYy4aVakW5drLkJNb7JgWqDWC-%2BDu6Kyk0k%2Bv7Lg%40mail.gmail.com.

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/A16BF32F-80DA-46E8-A21E-140079C7AA6D%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.