axis labels in BokehJS

All,

Is is possible to change axis labels using BokehJS? They appear to default to ‘x’ and ‘y’.

Thanks,

Dustin

Yes, you have to set the axis_label attribute on the axes. Here is an example that does so:

  http://bokeh.pydata.org/docs/gallery/elements.html

Bryan

···

On May 29, 2014, at 4:26 PM, Dustin Maas <[email protected]> wrote:

Is is possible to change axis labels using BokehJS? They appear to default to 'x' and 'y'.

I’m aware that you can set axis labels with the python interface, but I’m only using BokehJS.

···

On Thu, May 29, 2014 at 5:10 PM, Bryan Van de Ven [email protected] wrote:

On May 29, 2014, at 4:26 PM, Dustin Maas [email protected] wrote:

Is is possible to change axis labels using BokehJS? They appear to default to ‘x’ and ‘y’.

Yes, you have to set the axis_label attribute on the axes. Here is an example that does so:

    [http://bokeh.pydata.org/docs/gallery/elements.html](http://bokeh.pydata.org/docs/gallery/elements.html)

Bryan

You received this message because you are subscribed to a topic in the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/nV1tHbKzKTA/unsubscribe.

To unsubscribe from this group and all its topics, 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/DAF28E20-5CF2-4526-AAAB-C58B39FC823C%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Dustin,

Sorry I did not read carefully enough. If you are creating axes objects yourself, then you can do as follows:

  xaxis = Collections('LinearAxis').create(
    dimension: 0
    axis_label: 'foo'
    plot: plot_model.ref()
  )
  yaxis = Collections('LinearAxis').create(
    dimension: 1
    axis_label: 'bar'
    plot: plot_model.ref()
  )

If you are using Bokeh.plotting.make_plot then you will have to pick through the returned plot object's renderers and set axis_label on the axis objects. There is an issue to make selecting objects out of plots easier but it is not implemented yet.

Bryan

···

On May 29, 2014, at 6:22 PM, Dustin Maas <[email protected]> wrote:

I'm aware that you can set axis labels with the python interface, but I'm only using BokehJS.

On Thu, May 29, 2014 at 5:10 PM, Bryan Van de Ven <[email protected]> wrote:

On May 29, 2014, at 4:26 PM, Dustin Maas <[email protected]> wrote:

> Is is possible to change axis labels using BokehJS? They appear to default to 'x' and 'y'.

Yes, you have to set the axis_label attribute on the axes. Here is an example that does so:

        http://bokeh.pydata.org/docs/gallery/elements.html

Bryan

--
You received this message because you are subscribed to a topic in the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/nV1tHbKzKTA/unsubscribe\.
To unsubscribe from this group and all its topics, 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/DAF28E20-5CF2-4526-AAAB-C58B39FC823C%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/CABQfYdWRis3Yygs7XS9anxYYXFQHn8mLhKoCdetWBK%3DKA%2BYM1A%40mail.gmail.com\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Great. Is there a complete coffeescript example that uses the LinearAxis collection?

Thanks for your help.

···

On Thu, May 29, 2014 at 5:26 PM, Bryan Van de Ven [email protected] wrote:

Dustin,

Sorry I did not read carefully enough. If you are creating axes objects yourself, then you can do as follows:

xaxis = Collections(‘LinearAxis’).create(

dimension: 0

axis_label: 'foo'

plot: plot_model.ref()

)

yaxis = Collections(‘LinearAxis’).create(

dimension: 1

axis_label: 'bar'

plot: plot_model.ref()

)

If you are using Bokeh.plotting.make_plot then you will have to pick through the returned plot object’s renderers and set axis_label on the axis objects. There is an issue to make selecting objects out of plots easier but it is not implemented yet.

Bryan

On May 29, 2014, at 6:22 PM, Dustin Maas [email protected] wrote:

I’m aware that you can set axis labels with the python interface, but I’m only using BokehJS.

On Thu, May 29, 2014 at 5:10 PM, Bryan Van de Ven [email protected] wrote:

On May 29, 2014, at 4:26 PM, Dustin Maas [email protected] wrote:

Is is possible to change axis labels using BokehJS? They appear to default to ‘x’ and ‘y’.

Yes, you have to set the axis_label attribute on the axes. Here is an example that does so:

    [http://bokeh.pydata.org/docs/gallery/elements.html](http://bokeh.pydata.org/docs/gallery/elements.html)

Bryan

You received this message because you are subscribed to a topic in the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/nV1tHbKzKTA/unsubscribe.

To unsubscribe from this group and all its topics, 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/DAF28E20-5CF2-4526-AAAB-C58B39FC823C%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/CABQfYdWRis3Yygs7XS9anxYYXFQHn8mLhKoCdetWBK%3DKA%2BYM1A%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 a topic in the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/nV1tHbKzKTA/unsubscribe.

To unsubscribe from this group and all its topics, 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/1CB5AB7B-70A9-4655-941A-7BB17314892C%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Dustin,

My pleasure! You can look at:

  https://github.com/ContinuumIO/bokeh/blob/master/bokehjs/demo/coffee/gmap.coffee

It happens to set them to 'x' and 'y' but it should work to set them to other things. Let us know if there is any problems with it, though.

Thanks,

Bryan

···

On May 29, 2014, at 6:30 PM, Dustin Maas <[email protected]> wrote:

Great. Is there a complete coffeescript example that uses the LinearAxis collection?

Thanks for your help.

Perfect.

I would also like to place the plot in a particular div on my web page. Is there a simple way to put the plot/toolbar into, e.g., a div with id=“my_plot_div”?

···

On Thu, May 29, 2014 at 5:33 PM, Bryan Van de Ven [email protected] wrote:

On May 29, 2014, at 6:30 PM, Dustin Maas [email protected] wrote:

Great. Is there a complete coffeescript example that uses the LinearAxis collection?

Thanks for your help.

Dustin,

My pleasure! You can look at:

    [https://github.com/ContinuumIO/bokeh/blob/master/bokehjs/demo/coffee/gmap.coffee](https://github.com/ContinuumIO/bokeh/blob/master/bokehjs/demo/coffee/gmap.coffee)

It happens to set them to ‘x’ and ‘y’ but it should work to set them to other things. Let us know if there is any problems with it, though.

Thanks,

Bryan

You received this message because you are subscribed to a topic in the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/nV1tHbKzKTA/unsubscribe.

To unsubscribe from this group and all its topics, 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/ED917AA8-BF70-499F-9153-A872182BCDD7%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Dustin, there is not currently, though that would be a very useful function (and not hard to write I don't think). If you wanted to contribute a function in bokehjs/src/coffee/server/embed.coffee as a PR that would be very much appreciated! Otherwise you can submit at GH issue with the suggestion.

Thanks,

Bryan Van de Ven

···

On May 29, 2014, at 6:49 PM, Dustin Maas <[email protected]> wrote:

I would also like to place the plot in a particular div on my web page. Is there a simple way to put the plot/toolbar into, e.g., a div with id="my_plot_div"?

I came up with this technique to change axis labels using CustomJS:

  1. On your fig = figure(…) declaration, set x_axis_location and y_axis_location where you don’t want the final axis to be. For example, If you wanted to have the x-axis on the bottom and y-axis on the left in the final figure, set the following:

x_axis_location=‘above’, y_axis_location=‘right’

  1. Hide the original axes:

fig.xaxis.visible = None

fig.yaxis.visible = None

  1. Declare new axes and add them to the figure (i.e., add them to the opposite sides of the ones that you set in step 1):

from bokeh.models import LinearAxis

xaxis = LinearAxis(axis_label=“Initial x-axis label”)

yaxis = LinearAxis(axis_label=“Initial y-axis label”)

fig.add_layout(xaxis, ‘below’)

fig.add_layout(yaxis, ‘left’)

  1. Add the new axes to the arguments of CustomJS, where you can change their axis_labels:

callback = CustomJS(args=dict(source=source,

xaxis=xaxis,

yaxis=yaxis), code=“”"

xaxis.attributes.axis_label = “New x-axis label”;

yaxis.attributes.axis_label = “New y-axis label”;

xaxis.trigger(‘change’);

yaxis.trigger(‘change’);

“”")

···

On Friday, May 30, 2014 at 12:26:02 AM UTC+3, Dustin Maas wrote:

All,

Is is possible to change axis labels using BokehJS? They appear to default to ‘x’ and ‘y’.

Thanks,

Dustin

1 Like