Dynamically update plot axis label with button click

Hi all,

I am trying to update a plot axis label (on the bokeh server) with a button click using the following button callback code:

def button_clicked(self):
self.plot.xaxis.axis_label = ‘test’

and I get the error:

AttributeError: ‘Plot’ object has no attribute ‘xaxis’

I can update the axis label if I do it in the same function as creating the plot, but not outside of it.

Any thoughts?

Thanks for the help,
Logan

Maybe others know but i’d need a more complete code example to know.

···

Also, please let us know if you’re using 0.10 or latest 0.11dev build as server has been completely rewritten.

Sent from my iPod

On Dec 10, 2015, at 4:21 PM, Logan Abel [email protected] wrote:

Hi all,

I am trying to update a plot axis label (on the bokeh server) with a button click using the following button callback code:

def button_clicked(self):
self.plot.xaxis.axis_label = ‘test’

and I get the error:

AttributeError: ‘Plot’ object has no attribute ‘xaxis’

I can update the axis label if I do it in the same function as creating the plot, but not outside of it.

Any thoughts?

Thanks for the help,
Logan

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/43256dc7-7807-4a55-a80c-bf4962ba0930%40continuum.io.

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

I am using 0.10 at the moment.

Here is a more detailed overview of the code:

class PlotApp(HBox):
plot_button = Instance(Button)
plot = Instance(Plot)

@createmethod
def create(cls):
    obj = cls()
    obj.plot = figure(....)
    obj.plot.scatter(....)
    obj.plot.xaxis.axis_label = 'test1' #This works
    obj.plot_button = Button (....)
    obj.inputs = VBox(children=[obj.plot_button, obj.plot])

def setup_events(self):

“”"Attaches the on_change event to the value property of the widget.

“”"

super(PlotApp, self).setup_events()

self.plot_button.on_click(self.button_clicked)

def button_clicked(self):

self.plot.xaxis.axis_label = ‘test2’ #Breaks right here

It breaks when the button is clicked with the error

“AttributeError: ‘Plot’ object has no attribute ‘xaxis’”

but the first attempt to set the axis label does work.

···

On Friday, December 11, 2015 at 2:36:24 AM UTC-5, Sarah Bird wrote:

Maybe others know but i’d need a more complete code example to know.

Also, please let us know if you’re using 0.10 or latest 0.11dev build as server has been completely rewritten.

Sent from my iPod

On Dec 10, 2015, at 4:21 PM, Logan Abel [email protected] wrote:

Hi all,

I am trying to update a plot axis label (on the bokeh server) with a button click using the following button callback code:

def button_clicked(self):
self.plot.xaxis.axis_label = ‘test’

and I get the error:

AttributeError: ‘Plot’ object has no attribute ‘xaxis’

I can update the axis label if I do it in the same function as creating the plot, but not outside of it.

Any thoughts?

Thanks for the help,
Logan

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/43256dc7-7807-4a55-a80c-bf4962ba0930%40continuum.io.

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

I can’t run the code as
it’s not a complete example, but my guess
is because figure returns a Figure object not a Plot object.

···

On 12/11/15 7:31 AM, Logan Abel wrote:

I am using 0.10 at the moment.

    Here is a more detailed overview of the code:



    class PlotApp(HBox):

        plot_button = Instance(Button)

        plot = Instance(Plot)

       

        @createmethod

        def create(cls):

            obj = cls()

            obj.plot = figure(....)

            obj.plot.scatter(....)

            obj.plot.xaxis.axis_label = 'test1' #This works

            obj.plot_button = Button (....)

            obj.inputs = VBox(children=[obj.plot_button, obj.plot])

def setup_events(self):

“”"Attaches the on_change event to the value property of the widget.

“”"

super(PlotApp, self).setup_events()

self.plot_button.on_click(self.button_clicked)

def button_clicked(self):

self.plot.xaxis.axis_label = ‘test2’ #Breaks right here

It breaks when the button is clicked with the error

“AttributeError: ‘Plot’ object has no attribute ‘xaxis’”

but the first attempt to set the axis label does work.

    On Friday, December 11, 2015 at 2:36:24 AM UTC-5, Sarah Bird

wrote:

          Maybe others know but i'd need a more complete code

example to know.

          Also, please let us know if you're using 0.10 or latest

0.11dev build as server has been completely rewritten.

          Sent from my iPod
          On Dec 10, 2015, at 4:21 PM, Logan Abel <              >

wrote:

Hi all,

              I am trying to update a plot axis label (on the bokeh

server) with a button click using the following button
callback code:

              def button_clicked(self):

                  self.plot.xaxis.axis_label = 'test'



              and I get the error:



              AttributeError: 'Plot' object has no attribute 'xaxis'



              I can update the axis label if I do it in the same

function as creating the plot, but not outside of it.

              Any thoughts?



              Thanks for the help,

              Logan

            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                 .

To view this discussion on the web visit

  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/46bbcd88-d05b-40a4-8008-603e2b51d45f%40continuum.io?utm_medium=email&utm_source=footer)      .

For more options, visit .

[email protected]

[email protected]
https://groups.google.com/a/continuum.io/d/msgid/bokeh/43256dc7-7807-4a55-a80c-bf4962ba0930%40continuum.io.

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

          [https://groups.google.com/a/continuum.io/d/msgid/bokeh/46bbcd88-d05b-40a4-8008-603e2b51d45f%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/46bbcd88-d05b-40a4-8008-603e2b51d45f%40continuum.io)

https://groups.google.com/a/continuum.io/d/optout

Hi Sarah,

I am doing something similar to this example:

from bokeh.plotting import figure, output_file, show

output_file("axes.html")

p = figure(plot_width=400, plot_height=400)
p.circle([1,2,3,4,5], [2,5,8,2,7], size=10)

# change just some things about the x-axes
p.xaxis.axis_label = "Temp"
p.xaxis.axis_line_width = 3
p.xaxis.axis_line_color = "red"

# change just some things about the y-axes
p.yaxis.axis_label = "Pressure"
p.yaxis.major_label_text_color = "orange"
p.yaxis.major_label_orientation = "vertical"

# change things on all axes
p.axis.minor_tick_in = -3
p.axis.minor_tick_out = 6

show(p)

From the bokeh example page:

http://bokeh.pydata.org/en/0.9.3/docs/user_guide/styling.html

This is doing what I am trying to do, yet it doesn't seem to work with the server.

I am doing exactly what they did except with the server, and the AttributeError seems to be saying that it is a plot object.

It won't work for me to post the code as it is very long and requires a number of system dependencies at the moment for it to run.

Thank you for the help,
Logan

···

On Friday, December 11, 2015 at 10:26:03 PM UTC-5, Sarah Bird wrote:

    I can't run the code as

it’s not a complete example, but my guess
is because figure returns a Figure object not a Plot object.

On 12/11/15 7:31 AM, Logan Abel wrote:

def setup_events(self):

“”"Attaches the on_change event to the value property of the widget.

“”"

super(PlotApp, self).setup_events()

self.plot_button.on_click(self.button_clicked)

def button_clicked(self):

self.plot.xaxis.axis_label = ‘test2’ #Breaks right here

It breaks when the button is clicked with the error

“AttributeError: ‘Plot’ object has no attribute ‘xaxis’”

but the first attempt to set the axis label does work.

          Maybe others know but i'd need a more complete code

example to know.

          Also, please let us know if you're using 0.10 or latest

0.11dev build as server has been completely rewritten.

          Sent from my iPod
          On Dec 10, 2015, at 4:21 PM, Logan Abel <[email protected]              > > > > wrote:

Hi all,

              I am trying to update a plot axis label (on the bokeh

server) with a button click using the following button
callback code:

              def button_clicked(self):

                  self.plot.xaxis.axis_label = 'test'



              and I get the error:



              AttributeError: 'Plot' object has no attribute 'xaxis'



              I can update the axis label if I do it in the same

function as creating the plot, but not outside of it.

              Any thoughts?



              Thanks for the help,

              Logan

            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/43256dc7-7807-4a55-a80c-bf4962ba0930%40continuum.io?utm_medium=email&utm_source=footer)[https://groups.google.com/a/](https://groups.google.com/a/)continuum.io/d/msgid/bokeh/43256dc7-7807-4a55-a80c-bf4962ba0930%40continuum.io.

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

I am using 0.10 at the moment.

    Here is a more detailed overview of the code:



    class PlotApp(HBox):

        plot_button = Instance(Button)

        plot = Instance(Plot)

       

        @createmethod

        def create(cls):

            obj = cls()

            obj.plot = figure(....)

            obj.plot.scatter(....)

            obj.plot.xaxis.axis_label = 'test1' #This works

            obj.plot_button = Button (....)

            obj.inputs = VBox(children=[obj.plot_button, obj.plot])

       




    On Friday, December 11, 2015 at 2:36:24 AM UTC-5, Sarah Bird > > wrote:

  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/46bbcd88-d05b-40a4-8008-603e2b51d45f%40continuum.io?utm_medium=email&utm_source=footer)[https://groups.google.com/a/continuum.io/d/msgid/bokeh/46bbcd88-d05b-40a4-8008-603e2b51d45f%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/46bbcd88-d05b-40a4-8008-603e2b51d45f%40continuum.io).

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

Also, I think it should work to use the sliders example to try to update the plot axis labels, but I couldn’t find it on Github as it seemed to have been taken down.

···

On Friday, December 11, 2015 at 10:54:50 PM UTC-5, Logan Abel wrote:

Hi Sarah,

I am doing something similar to this example:

from bokeh.plotting import figure, output_file, show

output_file("axes.html")

p = figure(plot_width=400, plot_height=400)
p.circle([1,2,3,4,5], [2,5,8,2,7], size=10)

# change just some things about the x-axes
p.xaxis.axis_label = "Temp"
p.xaxis.axis_line_width = 3
p.xaxis.axis_line_color = "red"

# change just some things about the y-axes
p.yaxis.axis_label = "Pressure"
p.yaxis.major_label_text_color = "orange"
p.yaxis.major_label_orientation = "vertical"

# change things on all axes
p.axis.minor_tick_in = -3
p.axis.minor_tick_out = 6

show(p)

From the bokeh example page:

[http://bokeh.pydata.org/en/0.9.3/docs/user_guide/styling.html](http://bokeh.pydata.org/en/0.9.3/docs/user_guide/styling.html)

This is doing what I am trying to do, yet it doesn't seem to work with the server.

I am doing exactly what they did except with the server, and the AttributeError seems to be saying that it is a plot object.

It won't work for me to post the code as it is very long and requires a number of system dependencies at the moment for it to run.

Thank you for the help,
Logan

On Friday, December 11, 2015 at 10:26:03 PM UTC-5, Sarah Bird wrote:

    I can't run the code as

it’s not a complete example, but my guess
is because figure returns a Figure object not a Plot object.

On 12/11/15 7:31 AM, Logan Abel wrote:

def setup_events(self):

“”"Attaches the on_change event to the value property of the widget.

“”"

super(PlotApp, self).setup_events()

self.plot_button.on_click(self.button_clicked)

def button_clicked(self):

self.plot.xaxis.axis_label = ‘test2’ #Breaks right here

It breaks when the button is clicked with the error

“AttributeError: ‘Plot’ object has no attribute ‘xaxis’”

but the first attempt to set the axis label does work.

          Maybe others know but i'd need a more complete code

example to know.

          Also, please let us know if you're using 0.10 or latest

0.11dev build as server has been completely rewritten.

          Sent from my iPod
          On Dec 10, 2015, at 4:21 PM, Logan Abel <[email protected]              > > > > > wrote:

Hi all,

              I am trying to update a plot axis label (on the bokeh

server) with a button click using the following button
callback code:

              def button_clicked(self):

                  self.plot.xaxis.axis_label = 'test'



              and I get the error:



              AttributeError: 'Plot' object has no attribute 'xaxis'



              I can update the axis label if I do it in the same

function as creating the plot, but not outside of it.

              Any thoughts?



              Thanks for the help,

              Logan

            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/43256dc7-7807-4a55-a80c-bf4962ba0930%40continuum.io?utm_medium=email&utm_source=footer)[https://groups.google.com/a/](https://groups.google.com/a/)[continuum.io/d/msgid/bokeh/43256dc7-7807-4a55-a80c-bf4962ba0930%40continuum.io](http://continuum.io/d/msgid/bokeh/43256dc7-7807-4a55-a80c-bf4962ba0930%40continuum.io).

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

I am using 0.10 at the moment.

    Here is a more detailed overview of the code:



    class PlotApp(HBox):

        plot_button = Instance(Button)

        plot = Instance(Plot)

       

        @createmethod

        def create(cls):

            obj = cls()

            obj.plot = figure(....)

            obj.plot.scatter(....)

            obj.plot.xaxis.axis_label = 'test1' #This works

            obj.plot_button = Button (....)

            obj.inputs = VBox(children=[obj.plot_button, obj.plot])

       




    On Friday, December 11, 2015 at 2:36:24 AM UTC-5, Sarah Bird > > > wrote:

  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/46bbcd88-d05b-40a4-8008-603e2b51d45f%40continuum.io?utm_medium=email&utm_source=footer)[https://groups.google.com/a/continuum.io/d/msgid/bokeh/46bbcd88-d05b-40a4-8008-603e2b51d45f%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/46bbcd88-d05b-40a4-8008-603e2b51d45f%40continuum.io).

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

Hi Logan,

Would migrating to 0.11 be a feasible possibility for you? The 0.10 server is going to be fully removed. On a longer term view it’d definitely be a better strategy for you and it’d definitely help us building more use cases to test the new (better) server.

Please let us know so we can try to help you to port the example to the 0.11 server (you can install the 0.11 dev build release this week) or to try to debug your use case (that sadly will be limited to the deprecated 0.10 server).

Of course I’d strongly suggest you to migrate to 0.11 if it’s possible :slight_smile:

Thanks

Fabio

···

On Sat, Dec 12, 2015 at 8:13 AM, Logan Abel [email protected] wrote:

Also, I think it should work to use the sliders example to try to update the plot axis labels, but I couldn’t find it on Github as it seemed to have been taken down.

On Friday, December 11, 2015 at 10:54:50 PM UTC-5, Logan Abel wrote:

Hi Sarah,

I am doing something similar to this example:

from bokeh.plotting import figure, output_file, show

output_file("axes.html")

p = figure(plot_width=400, plot_height=400)
p.circle([1,2,3,4,5], [2,5,8,2,7], size=10)

# change just some things about the x-axes
p.xaxis.axis_label = "Temp"
p.xaxis.axis_line_width = 3
p.xaxis.axis_line_color = "red"

# change just some things about the y-axes
p.yaxis.axis_label = "Pressure"
p.yaxis.major_label_text_color = "orange"
p.yaxis.major_label_orientation = "vertical"

# change things on all axes
p.axis.minor_tick_in = -3
p.axis.minor_tick_out = 6

show(p)

From the bokeh example page:

[http://bokeh.pydata.org/en/0.9.3/docs/user_guide/styling.html](http://bokeh.pydata.org/en/0.9.3/docs/user_guide/styling.html)

This is doing what I am trying to do, yet it doesn't seem to work with the server.

I am doing exactly what they did except with the server, and the AttributeError seems to be saying that it is a plot object.

It won't work for me to post the code as it is very long and requires a number of system dependencies at the moment for it to run.

Thank you for the help,
Logan

On Friday, December 11, 2015 at 10:26:03 PM UTC-5, Sarah Bird wrote:

    I can't run the code as

it’s not a complete example, but my guess
is because figure returns a Figure object not a Plot object.

On 12/11/15 7:31 AM, Logan Abel wrote:

I am using 0.10 at the moment.

    Here is a more detailed overview of the code:



    class PlotApp(HBox):

        plot_button = Instance(Button)

        plot = Instance(Plot)

       

        @createmethod

        def create(cls):

            obj = cls()

            obj.plot = figure(....)

            obj.plot.scatter(....)

            obj.plot.xaxis.axis_label = 'test1' #This works

            obj.plot_button = Button (....)

            obj.inputs = VBox(children=[obj.plot_button, obj.plot])

def setup_events(self):

“”"Attaches the on_change event to the value property of the widget.

“”"

super(PlotApp, self).setup_events()

self.plot_button.on_click(self.button_clicked)

def button_clicked(self):

self.plot.xaxis.axis_label = ‘test2’ #Breaks right here

It breaks when the button is clicked with the error

“AttributeError: ‘Plot’ object has no attribute ‘xaxis’”

but the first attempt to set the axis label does work.

    On Friday, December 11, 2015 at 2:36:24 AM UTC-5, Sarah Bird

wrote:

          Maybe others know but i'd need a more complete code

example to know.

          Also, please let us know if you're using 0.10 or latest

0.11dev build as server has been completely rewritten.

          Sent from my iPod
          On Dec 10, 2015, at 4:21 PM, Logan Abel <[email protected]              >

wrote:

Hi all,

              I am trying to update a plot axis label (on the bokeh

server) with a button click using the following button
callback code:

              def button_clicked(self):

                  self.plot.xaxis.axis_label = 'test'



              and I get the error:



              AttributeError: 'Plot' object has no attribute 'xaxis'



              I can update the axis label if I do it in the same

function as creating the plot, but not outside of it.

              Any thoughts?



              Thanks for the help,

              Logan

            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/43256dc7-7807-4a55-a80c-bf4962ba0930%40continuum.io?utm_medium=email&utm_source=footer)[https://groups.google.com/a/](https://groups.google.com/a/)[continuum.io/d/msgid/bokeh/43256dc7-7807-4a55-a80c-bf4962ba0930%40continuum.io](http://continuum.io/d/msgid/bokeh/43256dc7-7807-4a55-a80c-bf4962ba0930%40continuum.io).

            For more options, visit [https://groups.google.com/a/continuum.io/d/optout](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/46bbcd88-d05b-40a4-8008-603e2b51d45f%40continuum.io?utm_medium=email&utm_source=footer)[https://groups.google.com/a/continuum.io/d/msgid/bokeh/46bbcd88-d05b-40a4-8008-603e2b51d45f%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/46bbcd88-d05b-40a4-8008-603e2b51d45f%40continuum.io).

  For more options, visit [https://groups.google.com/a/continuum.io/d/optout](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/bf5ce32b-2d9a-494b-895c-271988e1eed8%40continuum.io.

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

Fabio Pliger

Senior Software Engineer, Bokeh

Logan,

As an example of how much simpler it is to do this with the new 0.11 server, I only added the following line to the current GH examples/app/sliders.py example:

  plot.xaxis.axis_label = "%f, %f, %f, %f" % (a, b, w, k)

And it works great. For reference I have included the full (short) code below. With a 0.11 dev build just run

  bokeh server sliders.py --show

Here is the code, as you can see it is much simpler to write (no classes needed just simple functions):

import numpy as np

from bokeh.plotting import Figure
from bokeh.models import ColumnDataSource
from bokeh.models.widgets import HBox, Slider, TextInput, VBoxForm
from bokeh.io import curdoc

# Set up data
N = 200
x = np.linspace(0, 4*np.pi, N)
y = np.sin(x)
source = ColumnDataSource(data=dict(x=x, y=y))

# Set up plot
plot = Figure(plot_height=400, plot_width=400, title="my sine wave",
              tools="crosshair,pan,reset,resize,save,wheel_zoom",
              x_range=[0, 4*np.pi], y_range=[-2.5, 2.5])

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

# Set up widgets
text = TextInput(title="title", value='my sine wave')
offset = Slider(title="offset", value=0.0, start=-5.0, end=5.0, step=0.1)
amplitude = Slider(title="amplitude", value=1.0, start=-5.0, end=5.0)
phase = Slider(title="phase", value=0.0, start=0.0, end=2*np.pi)
freq = Slider(title="frequency", value=1.0, start=0.1, end=5.1)

# Set up callbacks
def update_title(attrname, old, new):
    plot.title = text.value

text.on_change('value', update_title)

def update_data(attrname, old, new):

    # Get the current slider values
    a = amplitude.value
    b = offset.value
    w = phase.value
    k = freq.value

    # Generate the new curve
    x = np.linspace(0, 4*np.pi, N)
    y = a*np.sin(k*x + w) + b

    # THIS IS THE LINE I ADDED TO UPDATE AXIS LABEL
    plot.xaxis.axis_label = "%f, %f, %f, %f" % (a, b, w, k)

    source.data = dict(x=x, y=y)

for w in [offset, amplitude, phase, freq]:
    w.on_change('value', update_data)

# Set up layouts and add to document
inputs = VBoxForm(children=[text, offset, amplitude, phase, freq])

curdoc().add_root(HBox(children=[inputs, plot]))

···

On Dec 12, 2015, at 12:07 PM, Fabio Pliger <[email protected]> wrote:

Hi Logan,

Would migrating to 0.11 be a feasible possibility for you? The 0.10 server is going to be fully removed. On a longer term view it'd definitely be a better strategy for you and it'd definitely help us building more use cases to test the new (better) server.

Please let us know so we can try to help you to port the example to the 0.11 server (you can install the 0.11 dev build release this week) or to try to debug your use case (that sadly will be limited to the deprecated 0.10 server).

Of course I'd strongly suggest you to migrate to 0.11 if it's possible :slight_smile:

Thanks

Fabio

On Sat, Dec 12, 2015 at 8:13 AM, Logan Abel <[email protected]> wrote:
Also, I think it should work to use the sliders example to try to update the plot axis labels, but I couldn't find it on Github as it seemed to have been taken down.

On Friday, December 11, 2015 at 10:54:50 PM UTC-5, Logan Abel wrote:
Hi Sarah,

I am doing something similar to this example:

from bokeh.plotting import figure, output_file, show

output_file("axes.html")

p = figure(plot_width=400, plot_height=400)
p.circle([1,2,3,4,5], [2,5,8,2,7], size=10)

# change just some things about the x-axes
p.xaxis.axis_label = "Temp"
p.xaxis.axis_line_width = 3
p.xaxis.axis_line_color = "red"

# change just some things about the y-axes
p.yaxis.axis_label = "Pressure"
p.yaxis.major_label_text_color = "orange"
p.yaxis.major_label_orientation = "vertical"

# change things on all axes
p.axis.minor_tick_in = -3
p.axis.minor_tick_out = 6

show(p)

From the bokeh example page:

http://bokeh.pydata.org/en/0.9.3/docs/user_guide/styling.html

This is doing what I am trying to do, yet it doesn't seem to work with the server.

I am doing exactly what they did except with the server, and the AttributeError seems to be saying that it is a plot object.

It won't work for me to post the code as it is very long and requires a number of system dependencies at the moment for it to run.

Thank you for the help,
Logan

On Friday, December 11, 2015 at 10:26:03 PM UTC-5, Sarah Bird wrote:
I can't run the code as it's not a complete example, but my guess is because `figure` returns a Figure object not a Plot object.

On 12/11/15 7:31 AM, Logan Abel wrote:

I am using 0.10 at the moment.

Here is a more detailed overview of the code:

class PlotApp(HBox):
    plot_button = Instance(Button)
    plot = Instance(Plot)
    
    @createmethod
    def create(cls):
        obj = cls()
        obj.plot = figure(....)
        obj.plot.scatter(....)
        obj.plot.xaxis.axis_label = 'test1' #This works
        obj.plot_button = Button (....)
        obj.inputs = VBox(children=[obj.plot_button, obj.plot])
    
def setup_events(self):
"""Attaches the on_change event to the value property of the widget.
"""
super(PlotApp, self).setup_events()
self.plot_button.on_click(self.button_clicked)
def button_clicked(self):
self.plot.xaxis.axis_label = 'test2' #Breaks right here
It breaks when the button is clicked with the error
"AttributeError: 'Plot' object has no attribute 'xaxis'"
but the first attempt to set the axis label does work.

On Friday, December 11, 2015 at 2:36:24 AM UTC-5, Sarah Bird wrote:
Maybe others know but i'd need a more complete code example to know.

Also, please let us know if you're using 0.10 or latest 0.11dev build as server has been completely rewritten.

Sent from my iPod

On Dec 10, 2015, at 4:21 PM, Logan Abel <[email protected]> wrote:

Hi all,

I am trying to update a plot axis label (on the bokeh server) with a button click using the following button callback code:

def button_clicked(self):
    self.plot.xaxis.axis_label = 'test'

and I get the error:

AttributeError: 'Plot' object has no attribute 'xaxis'

I can update the axis label if I do it in the same function as creating the plot, but not outside of it.

Any thoughts?

Thanks for the help,
Logan
--
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/43256dc7-7807-4a55-a80c-bf4962ba0930%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/46bbcd88-d05b-40a4-8008-603e2b51d45f%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/bf5ce32b-2d9a-494b-895c-271988e1eed8%40continuum.io.

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

--
Fabio Pliger
Senior Software Engineer, Bokeh

--
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/CAPVmnqBcR%2BG5M0qdmtVQTkhmF_AMSAvGc-dFz3bbhs67QyYq%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

One correction, I mistyped the command line to execute, it is:

  bokeh serve sliders.py --show

Thanks,

Bryan

···

On Dec 12, 2015, at 12:17 PM, Bryan Van de Ven <[email protected]> wrote:

Logan,

As an example of how much simpler it is to do this with the new 0.11 server, I only added the following line to the current GH examples/app/sliders.py example:

  plot.xaxis.axis_label = "%f, %f, %f, %f" % (a, b, w, k)

And it works great. For reference I have included the full (short) code below. With a 0.11 dev build just run

  bokeh server sliders.py --show

Here is the code, as you can see it is much simpler to write (no classes needed just simple functions):

import numpy as np

from bokeh.plotting import Figure
from bokeh.models import ColumnDataSource
from bokeh.models.widgets import HBox, Slider, TextInput, VBoxForm
from bokeh.io import curdoc

# Set up data
N = 200
x = np.linspace(0, 4*np.pi, N)
y = np.sin(x)
source = ColumnDataSource(data=dict(x=x, y=y))

# Set up plot
plot = Figure(plot_height=400, plot_width=400, title="my sine wave",
             tools="crosshair,pan,reset,resize,save,wheel_zoom",
             x_range=[0, 4*np.pi], y_range=[-2.5, 2.5])

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

# Set up widgets
text = TextInput(title="title", value='my sine wave')
offset = Slider(title="offset", value=0.0, start=-5.0, end=5.0, step=0.1)
amplitude = Slider(title="amplitude", value=1.0, start=-5.0, end=5.0)
phase = Slider(title="phase", value=0.0, start=0.0, end=2*np.pi)
freq = Slider(title="frequency", value=1.0, start=0.1, end=5.1)

# Set up callbacks
def update_title(attrname, old, new):
   plot.title = text.value

text.on_change('value', update_title)

def update_data(attrname, old, new):

   # Get the current slider values
   a = amplitude.value
   b = offset.value
   w = phase.value
   k = freq.value

   # Generate the new curve
   x = np.linspace(0, 4*np.pi, N)
   y = a*np.sin(k*x + w) + b

   # THIS IS THE LINE I ADDED TO UPDATE AXIS LABEL
   plot.xaxis.axis_label = "%f, %f, %f, %f" % (a, b, w, k)

   source.data = dict(x=x, y=y)

for w in [offset, amplitude, phase, freq]:
   w.on_change('value', update_data)

# Set up layouts and add to document
inputs = VBoxForm(children=[text, offset, amplitude, phase, freq])

curdoc().add_root(HBox(children=[inputs, plot]))

On Dec 12, 2015, at 12:07 PM, Fabio Pliger <[email protected]> wrote:

Hi Logan,

Would migrating to 0.11 be a feasible possibility for you? The 0.10 server is going to be fully removed. On a longer term view it'd definitely be a better strategy for you and it'd definitely help us building more use cases to test the new (better) server.

Please let us know so we can try to help you to port the example to the 0.11 server (you can install the 0.11 dev build release this week) or to try to debug your use case (that sadly will be limited to the deprecated 0.10 server).

Of course I'd strongly suggest you to migrate to 0.11 if it's possible :slight_smile:

Thanks

Fabio

On Sat, Dec 12, 2015 at 8:13 AM, Logan Abel <[email protected]> wrote:
Also, I think it should work to use the sliders example to try to update the plot axis labels, but I couldn't find it on Github as it seemed to have been taken down.

On Friday, December 11, 2015 at 10:54:50 PM UTC-5, Logan Abel wrote:
Hi Sarah,

I am doing something similar to this example:

from bokeh.plotting import figure, output_file, show

output_file("axes.html")

p = figure(plot_width=400, plot_height=400)
p.circle([1,2,3,4,5], [2,5,8,2,7], size=10)

# change just some things about the x-axes
p.xaxis.axis_label = "Temp"
p.xaxis.axis_line_width = 3
p.xaxis.axis_line_color = "red"

# change just some things about the y-axes
p.yaxis.axis_label = "Pressure"
p.yaxis.major_label_text_color = "orange"
p.yaxis.major_label_orientation = "vertical"

# change things on all axes
p.axis.minor_tick_in = -3
p.axis.minor_tick_out = 6

show(p)

From the bokeh example page:

http://bokeh.pydata.org/en/0.9.3/docs/user_guide/styling.html

This is doing what I am trying to do, yet it doesn't seem to work with the server.

I am doing exactly what they did except with the server, and the AttributeError seems to be saying that it is a plot object.

It won't work for me to post the code as it is very long and requires a number of system dependencies at the moment for it to run.

Thank you for the help,
Logan

On Friday, December 11, 2015 at 10:26:03 PM UTC-5, Sarah Bird wrote:
I can't run the code as it's not a complete example, but my guess is because `figure` returns a Figure object not a Plot object.

On 12/11/15 7:31 AM, Logan Abel wrote:

I am using 0.10 at the moment.

Here is a more detailed overview of the code:

class PlotApp(HBox):
   plot_button = Instance(Button)
   plot = Instance(Plot)

   @createmethod
   def create(cls):
       obj = cls()
       obj.plot = figure(....)
       obj.plot.scatter(....)
       obj.plot.xaxis.axis_label = 'test1' #This works
       obj.plot_button = Button (....)
       obj.inputs = VBox(children=[obj.plot_button, obj.plot])

def setup_events(self):
"""Attaches the on_change event to the value property of the widget.
"""
super(PlotApp, self).setup_events()
self.plot_button.on_click(self.button_clicked)
def button_clicked(self):
self.plot.xaxis.axis_label = 'test2' #Breaks right here
It breaks when the button is clicked with the error
"AttributeError: 'Plot' object has no attribute 'xaxis'"
but the first attempt to set the axis label does work.

On Friday, December 11, 2015 at 2:36:24 AM UTC-5, Sarah Bird wrote:
Maybe others know but i'd need a more complete code example to know.

Also, please let us know if you're using 0.10 or latest 0.11dev build as server has been completely rewritten.

Sent from my iPod

On Dec 10, 2015, at 4:21 PM, Logan Abel <[email protected]> wrote:

Hi all,

I am trying to update a plot axis label (on the bokeh server) with a button click using the following button callback code:

def button_clicked(self):
   self.plot.xaxis.axis_label = 'test'

and I get the error:

AttributeError: 'Plot' object has no attribute 'xaxis'

I can update the axis label if I do it in the same function as creating the plot, but not outside of it.

Any thoughts?

Thanks for the help,
Logan
--
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/43256dc7-7807-4a55-a80c-bf4962ba0930%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/46bbcd88-d05b-40a4-8008-603e2b51d45f%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+u[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/bf5ce32b-2d9a-494b-895c-271988e1eed8%40continuum.io.

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

--
Fabio Pliger
Senior Software Engineer, Bokeh

--
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/CAPVmnqBcR%2BG5M0qdmtVQTkhmF_AMSAvGc-dFz3bbhs67QyYq%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Bryan, Fabio, and Sarah,

Thank you both for the help! I tried out the example and will navigate over to 0.11.

Best,
Logan

···

On Saturday, December 12, 2015 at 1:18:14 PM UTC-5, Bryan Van de ven wrote:

One correction, I mistyped the command line to execute, it is:

    bokeh serve sliders.py --show

Thanks,

Bryan

On Dec 12, 2015, at 12:17 PM, Bryan Van de Ven [email protected] wrote:

Logan,

As an example of how much simpler it is to do this with the new 0.11 server, I only added the following line to the current GH examples/app/sliders.py example:

    plot.xaxis.axis_label = "%f, %f, %f, %f" % (a, b, w, k)

And it works great. For reference I have included the full (short) code below. With a 0.11 dev build just run

    bokeh server sliders.py --show

Here is the code, as you can see it is much simpler to write (no classes needed just simple functions):

import numpy as np

from bokeh.plotting import Figure

from bokeh.models import ColumnDataSource

from bokeh.models.widgets import HBox, Slider, TextInput, VBoxForm

from bokeh.io import curdoc

Set up data

N = 200

x = np.linspace(0, 4*np.pi, N)

y = np.sin(x)

source = ColumnDataSource(data=dict(x=x, y=y))

Set up plot

plot = Figure(plot_height=400, plot_width=400, title=“my sine wave”,

         tools="crosshair,pan,reset,resize,save,wheel_zoom",
         x_range=[0, 4*np.pi], y_range=[-2.5, 2.5])

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

Set up widgets

text = TextInput(title=“title”, value=‘my sine wave’)

offset = Slider(title=“offset”, value=0.0, start=-5.0, end=5.0, step=0.1)

amplitude = Slider(title=“amplitude”, value=1.0, start=-5.0, end=5.0)

phase = Slider(title=“phase”, value=0.0, start=0.0, end=2*np.pi)

freq = Slider(title=“frequency”, value=1.0, start=0.1, end=5.1)

Set up callbacks

def update_title(attrname, old, new):

plot.title = text.value

text.on_change(‘value’, update_title)

def update_data(attrname, old, new):

Get the current slider values

a = amplitude.value

b = offset.value

w = phase.value

k = freq.value

Generate the new curve

x = np.linspace(0, 4*np.pi, N)

y = anp.sin(kx + w) + b

THIS IS THE LINE I ADDED TO UPDATE AXIS LABEL

plot.xaxis.axis_label = “%f, %f, %f, %f” % (a, b, w, k)

source.data = dict(x=x, y=y)

for w in [offset, amplitude, phase, freq]:

w.on_change(‘value’, update_data)

Set up layouts and add to document

inputs = VBoxForm(children=[text, offset, amplitude, phase, freq])

curdoc().add_root(HBox(children=[inputs, plot]))

On Dec 12, 2015, at 12:07 PM, Fabio Pliger [email protected] wrote:

Hi Logan,

Would migrating to 0.11 be a feasible possibility for you? The 0.10 server is going to be fully removed. On a longer term view it’d definitely be a better strategy for you and it’d definitely help us building more use cases to test the new (better) server.

Please let us know so we can try to help you to port the example to the 0.11 server (you can install the 0.11 dev build release this week) or to try to debug your use case (that sadly will be limited to the deprecated 0.10 server).

Of course I’d strongly suggest you to migrate to 0.11 if it’s possible :slight_smile:

Thanks

Fabio

On Sat, Dec 12, 2015 at 8:13 AM, Logan Abel [email protected] wrote:

Also, I think it should work to use the sliders example to try to update the plot axis labels, but I couldn’t find it on Github as it seemed to have been taken down.

On Friday, December 11, 2015 at 10:54:50 PM UTC-5, Logan Abel wrote:

Hi Sarah,

I am doing something similar to this example:

from bokeh.plotting import figure, output_file, show

output_file(“axes.html”)

p = figure(plot_width=400, plot_height=400)

p.circle([1,2,3,4,5], [2,5,8,2,7], size=10)

change just some things about the x-axes

p.xaxis.axis_label = “Temp”

p.xaxis.axis_line_width = 3

p.xaxis.axis_line_color = “red”

change just some things about the y-axes

p.yaxis.axis_label = “Pressure”

p.yaxis.major_label_text_color = “orange”

p.yaxis.major_label_orientation = “vertical”

change things on all axes

p.axis.minor_tick_in = -3

p.axis.minor_tick_out = 6

show§

From the bokeh example page:

http://bokeh.pydata.org/en/0.9.3/docs/user_guide/styling.html

This is doing what I am trying to do, yet it doesn’t seem to work with the server.

I am doing exactly what they did except with the server, and the AttributeError seems to be saying that it is a plot object.

It won’t work for me to post the code as it is very long and requires a number of system dependencies at the moment for it to run.

Thank you for the help,

Logan

On Friday, December 11, 2015 at 10:26:03 PM UTC-5, Sarah Bird wrote:

I can’t run the code as it’s not a complete example, but my guess is because figure returns a Figure object not a Plot object.

On 12/11/15 7:31 AM, Logan Abel wrote:

I am using 0.10 at the moment.

Here is a more detailed overview of the code:

class PlotApp(HBox):

plot_button = Instance(Button)

plot = Instance(Plot)

@createmethod

def create(cls):

   obj = cls()
   obj.plot = figure(....)
   obj.plot.scatter(....)
   obj.plot.xaxis.axis_label = 'test1' #This works
   obj.plot_button = Button (....)
   obj.inputs = VBox(children=[obj.plot_button, obj.plot])

def setup_events(self):

“”"Attaches the on_change event to the value property of the widget.

“”"

super(PlotApp, self).setup_events()

self.plot_button.on_click(self.button_clicked)

def button_clicked(self):

self.plot.xaxis.axis_label = ‘test2’ #Breaks right here

It breaks when the button is clicked with the error

“AttributeError: ‘Plot’ object has no attribute ‘xaxis’”

but the first attempt to set the axis label does work.

On Friday, December 11, 2015 at 2:36:24 AM UTC-5, Sarah Bird wrote:

Maybe others know but i’d need a more complete code example to know.

Also, please let us know if you’re using 0.10 or latest 0.11dev build as server has been completely rewritten.

Sent from my iPod

On Dec 10, 2015, at 4:21 PM, Logan Abel [email protected] wrote:

Hi all,

I am trying to update a plot axis label (on the bokeh server) with a button click using the following button callback code:

def button_clicked(self):

self.plot.xaxis.axis_label = ‘test’

and I get the error:

AttributeError: ‘Plot’ object has no attribute ‘xaxis’

I can update the axis label if I do it in the same function as creating the plot, but not outside of it.

Any thoughts?

Thanks for the help,

Logan


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/43256dc7-7807-4a55-a80c-bf4962ba0930%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/46bbcd88-d05b-40a4-8008-603e2b51d45f%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/bf5ce32b-2d9a-494b-895c-271988e1eed8%40continuum.io.

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


Fabio Pliger

Senior Software Engineer, Bokeh


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/CAPVmnqBcR%2BG5M0qdmtVQTkhmF_AMSAvGc-dFz3bbhs67QyYq%3DQ%40mail.gmail.com.

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