Bar charts

Hi,

I am trying to build a document an example similar in spirit to taylor_server.py but with a bar chart instead (rather than a regular line plot). Assuming that my data is, for example:

labels = [‘foo’, bar’]

values = [-1, -2]

What changes specifically do I need to make?

The original taylor_server.py has roughly the following code to create the plot (ignoring the other widgets for now). Any pointers (even minor modifications to the code below) would be greatly appreciated!

from bokeh.objects import Plot, DataRange1d, LinearAxis, ColumnDataSource, Glyph, Grid, Legend

from bokeh.widgetobjects import VBox,

from bokeh.glyphs import Patch, Line, Text

from bokeh.document import Document

from bokeh.session import Session

source = ColumnDataSource(data=dict(

x = [1, 2, 3],

y = [0, 10, 100]

))

xdr = DataRange1d(sources=[source.columns(“x”)])

ydr = DataRange1d(sources=[source.columns(“y”)])

plot = Plot(x_range=xdr, y_range=ydr, plot_width=800, plot_height=400)

line_f = Line(x=“x”, y=“y”, line_color=“blue”, line_width=2)

line_f_glyph = Glyph(data_source=source, xdata_range=xdr, ydata_range=ydr, glyph=line_f)

plot.renderers.append(line_f_glyph)

xaxis = LinearAxis(plot=plot)

plot.below.append(xaxis)

yaxis = LinearAxis(plot=plot)

plot.left.append(yaxis)

xgrid = Grid(plot=plot, dimension=0, ticker=xaxis.ticker)

ygrid = Grid(plot=plot, dimension=1, ticker=yaxis.ticker)

layout = VBox(children=[plot])

document.add(layout)

Josh

Hello Josh,

It seems like you are trying to set up a categorical x-axis; am I correct in assuming that?

Unfortunately Bokeh does not support changing categorical axes at the moment; there is an open issue to track this behavior, and a related gist I’ve written up that demonstrates a code snippet that should work (but doesn’t currently).

I’ll make a note to ping you if I can resolve this in the near future.

Thanks!

Karan

···

On Wed, Aug 27, 2014 at 10:56 AM, Josh Wasserstein [email protected] wrote:

Hi,

I am trying to build a document an example similar in spirit to taylor_server.py but with a bar chart instead (rather than a regular line plot). Assuming that my data is, for example:

labels = [‘foo’, bar’]

values = [-1, -2]

What changes specifically do I need to make?

The original taylor_server.py has roughly the following code to create the plot (ignoring the other widgets for now). Any pointers (even minor modifications to the code below) would be greatly appreciated!

from bokeh.objects import Plot, DataRange1d, LinearAxis, ColumnDataSource, Glyph, Grid, Legend

from bokeh.widgetobjects import VBox,

from bokeh.glyphs import Patch, Line, Text

from bokeh.document import Document

from bokeh.session import Session

source = ColumnDataSource(data=dict(

x = [1, 2, 3],

y = [0, 10, 100]

))

xdr = DataRange1d(sources=[source.columns(“x”)])

ydr = DataRange1d(sources=[source.columns(“y”)])

plot = Plot(x_range=xdr, y_range=ydr, plot_width=800, plot_height=400)

line_f = Line(x=“x”, y=“y”, line_color=“blue”, line_width=2)

line_f_glyph = Glyph(data_source=source, xdata_range=xdr, ydata_range=ydr, glyph=line_f)

plot.renderers.append(line_f_glyph)

xaxis = LinearAxis(plot=plot)

plot.below.append(xaxis)

yaxis = LinearAxis(plot=plot)

plot.left.append(yaxis)

xgrid = Grid(plot=plot, dimension=0, ticker=xaxis.ticker)

ygrid = Grid(plot=plot, dimension=1, ticker=yaxis.ticker)

layout = VBox(children=[plot])

document.add(layout)

Josh

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/CAD4ivxX6gXsWaVTvQ_dcUjdnqWhfyYDF23kR%3DoTGsWvBtuqmSw%40mail.gmail.com.

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

Thanks Karan. You are correct. That’s exactly what I am looking for. I guess that there is no way to do this now. Would it be possible to have the bar plot come from matplotlib? (perhaps rendered as a bitmap). Is this something that Bokeh supports?

More generally, and I understand that this departs from the original question, can I use matplotlib to render a figure as a bitmap and then use some Bokeh widget to display it within an HBox VBox, or equivalent?

Josh

···

On Wed, Aug 27, 2014 at 12:18 PM, Karan Dodia [email protected] wrote:

Hello Josh,

It seems like you are trying to set up a categorical x-axis; am I correct in assuming that?

Unfortunately Bokeh does not support changing categorical axes at the moment; there is an open issue to track this behavior, and a related gist I’ve written up that demonstrates a code snippet that should work (but doesn’t currently).

I’ll make a note to ping you if I can resolve this in the near future.

Thanks!

Karan

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/CAOvoNRQXa3b1W5NvBbkQgWwAaRauH71%2Bf2v87OK0Mg_mkLJNKw%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 10:56 AM, Josh Wasserstein [email protected] wrote:

Hi,

I am trying to build a document an example similar in spirit to taylor_server.py but with a bar chart instead (rather than a regular line plot). Assuming that my data is, for example:

labels = [‘foo’, bar’]

values = [-1, -2]

What changes specifically do I need to make?

The original taylor_server.py has roughly the following code to create the plot (ignoring the other widgets for now). Any pointers (even minor modifications to the code below) would be greatly appreciated!

from bokeh.objects import Plot, DataRange1d, LinearAxis, ColumnDataSource, Glyph, Grid, Legend

from bokeh.widgetobjects import VBox,

from bokeh.glyphs import Patch, Line, Text

from bokeh.document import Document

from bokeh.session import Session

source = ColumnDataSource(data=dict(

x = [1, 2, 3],

y = [0, 10, 100]

))

xdr = DataRange1d(sources=[source.columns(“x”)])

ydr = DataRange1d(sources=[source.columns(“y”)])

plot = Plot(x_range=xdr, y_range=ydr, plot_width=800, plot_height=400)

line_f = Line(x=“x”, y=“y”, line_color=“blue”, line_width=2)

line_f_glyph = Glyph(data_source=source, xdata_range=xdr, ydata_range=ydr, glyph=line_f)

plot.renderers.append(line_f_glyph)

xaxis = LinearAxis(plot=plot)

plot.below.append(xaxis)

yaxis = LinearAxis(plot=plot)

plot.left.append(yaxis)

xgrid = Grid(plot=plot, dimension=0, ticker=xaxis.ticker)

ygrid = Grid(plot=plot, dimension=1, ticker=yaxis.ticker)

layout = VBox(children=[plot])

document.add(layout)

Josh

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/CAD4ivxX6gXsWaVTvQ_dcUjdnqWhfyYDF23kR%3DoTGsWvBtuqmSw%40mail.gmail.com.

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

*> *can I use matplotlib to render a figure as a bitmap and then use some Bokeh widget to display it within an HBox VBox, or equivalent?

Short answer: yes. Disclaimer: this is a terrible idea; a 4th-class solution at best.

If you need something by the end of this week, here’s what you could do:

Render your MPL plot as a bitmap, and then use Bokeh’s image_rgba glyph to render it in an appropriately-sized Bokeh plot. I would also suggest turning off the plot title, axes, and tools to remove visual clutter. Then the widget—as in the taylor_server example—can be bound to a function to update the MPL plot, re-render to bitmap, load into image_rgba, etc.

This should work in theory, although I would again strongly hazard against using this method.

We the Bokeh team are constantly trying to strike a balance between closing off issues for smaller use-cases like this one and developing larger features to broaden Bokeh’s capabilities, but it’s clear that this can be bumped in priority.

Regards,

Karan

···

On Wed, Aug 27, 2014 at 12:48 PM, Josh Wasserstein [email protected] wrote:

Thanks Karan. You are correct. That’s exactly what I am looking for. I guess that there is no way to do this now. Would it be possible to have the bar plot come from matplotlib? (perhaps rendered as a bitmap). Is this something that Bokeh supports?

More generally, and I understand that this departs from the original question, can I use matplotlib to render a figure as a bitmap and then use some Bokeh widget to display it within an HBox VBox, or equivalent?

Josh

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/CAD4ivxUDCTyEJHDMZohAZa4sP_7Vu-f2CJON%2BVYgsDU5AdUr4g%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 12:18 PM, Karan Dodia [email protected] wrote:

Hello Josh,

It seems like you are trying to set up a categorical x-axis; am I correct in assuming that?

Unfortunately Bokeh does not support changing categorical axes at the moment; there is an open issue to track this behavior, and a related gist I’ve written up that demonstrates a code snippet that should work (but doesn’t currently).

I’ll make a note to ping you if I can resolve this in the near future.

Thanks!

Karan

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].

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

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAOvoNRQXa3b1W5NvBbkQgWwAaRauH71%2Bf2v87OK0Mg_mkLJNKw%40mail.gmail.com.

On Wed, Aug 27, 2014 at 10:56 AM, Josh Wasserstein [email protected] wrote:

Hi,

I am trying to build a document an example similar in spirit to taylor_server.py but with a bar chart instead (rather than a regular line plot). Assuming that my data is, for example:

labels = [‘foo’, bar’]

values = [-1, -2]

What changes specifically do I need to make?

The original taylor_server.py has roughly the following code to create the plot (ignoring the other widgets for now). Any pointers (even minor modifications to the code below) would be greatly appreciated!

from bokeh.objects import Plot, DataRange1d, LinearAxis, ColumnDataSource, Glyph, Grid, Legend

from bokeh.widgetobjects import VBox,

from bokeh.glyphs import Patch, Line, Text

from bokeh.document import Document

from bokeh.session import Session

source = ColumnDataSource(data=dict(

x = [1, 2, 3],

y = [0, 10, 100]

))

xdr = DataRange1d(sources=[source.columns(“x”)])

ydr = DataRange1d(sources=[source.columns(“y”)])

plot = Plot(x_range=xdr, y_range=ydr, plot_width=800, plot_height=400)

line_f = Line(x=“x”, y=“y”, line_color=“blue”, line_width=2)

line_f_glyph = Glyph(data_source=source, xdata_range=xdr, ydata_range=ydr, glyph=line_f)

plot.renderers.append(line_f_glyph)

xaxis = LinearAxis(plot=plot)

plot.below.append(xaxis)

yaxis = LinearAxis(plot=plot)

plot.left.append(yaxis)

xgrid = Grid(plot=plot, dimension=0, ticker=xaxis.ticker)

ygrid = Grid(plot=plot, dimension=1, ticker=yaxis.ticker)

layout = VBox(children=[plot])

document.add(layout)

Josh

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/CAD4ivxX6gXsWaVTvQ_dcUjdnqWhfyYDF23kR%3DoTGsWvBtuqmSw%40mail.gmail.com.

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

Thanks Karan. That makes sense. For now, I am just hoping to pitch the use of Bokeh in my team in a presentation tomorrow that includes a web front end that pulls data from a database ( wish me luck! :))

So just for me to get this running for now: If I have an image that is 800*600. How should I make the call to image_rgba?

For a quick demo, I have tried:

f = plt.figure(figsize=(12,6))

ax = f.add_subplot(111)

ax.plot([1,2,3,4])

plt.savefig(‘temp.png’)

import matplotlib.image as mpimg

image = mpimg.imread(‘temp.png’)

plot = image_rgba(image, x=0, y=0, dw=image.shape[0], dh=image.shape[1])

but I get:

RunTimeError:Columns need to be 1D (image is not)

Josh

···

On Wed, Aug 27, 2014 at 2:26 PM, Karan Dodia [email protected] wrote:

*> *can I use matplotlib to render a figure as a bitmap and then use some Bokeh widget to display it within an HBox VBox, or equivalent?

Short answer: yes. Disclaimer: this is a terrible idea; a 4th-class solution at best.

If you need something by the end of this week, here’s what you could do:

Render your MPL plot as a bitmap, and then use Bokeh’s image_rgba glyph to render it in an appropriately-sized Bokeh plot. I would also suggest turning off the plot title, axes, and tools to remove visual clutter. Then the widget—as in the taylor_server example—can be bound to a function to update the MPL plot, re-render to bitmap, load into image_rgba, etc.

This should work in theory, although I would again strongly hazard against using this method.

We the Bokeh team are constantly trying to strike a balance between closing off issues for smaller use-cases like this one and developing larger features to broaden Bokeh’s capabilities, but it’s clear that this can be bumped in priority.

Regards,

Karan

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/CAOvoNRQawtOc8f35WB_xNj3R0HmqOHXj-kxQUDHuDSF6Z-iMAw%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 12:48 PM, Josh Wasserstein [email protected] wrote:

Thanks Karan. You are correct. That’s exactly what I am looking for. I guess that there is no way to do this now. Would it be possible to have the bar plot come from matplotlib? (perhaps rendered as a bitmap). Is this something that Bokeh supports?

More generally, and I understand that this departs from the original question, can I use matplotlib to render a figure as a bitmap and then use some Bokeh widget to display it within an HBox VBox, or equivalent?

Josh

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/CAD4ivxUDCTyEJHDMZohAZa4sP_7Vu-f2CJON%2BVYgsDU5AdUr4g%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 12:18 PM, Karan Dodia [email protected] wrote:

Hello Josh,

It seems like you are trying to set up a categorical x-axis; am I correct in assuming that?

Unfortunately Bokeh does not support changing categorical axes at the moment; there is an open issue to track this behavior, and a related gist I’ve written up that demonstrates a code snippet that should work (but doesn’t currently).

I’ll make a note to ping you if I can resolve this in the near future.

Thanks!

Karan

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].

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

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAOvoNRQXa3b1W5NvBbkQgWwAaRauH71%2Bf2v87OK0Mg_mkLJNKw%40mail.gmail.com.

On Wed, Aug 27, 2014 at 10:56 AM, Josh Wasserstein [email protected] wrote:

Hi,

I am trying to build a document an example similar in spirit to taylor_server.py but with a bar chart instead (rather than a regular line plot). Assuming that my data is, for example:

labels = [‘foo’, bar’]

values = [-1, -2]

What changes specifically do I need to make?

The original taylor_server.py has roughly the following code to create the plot (ignoring the other widgets for now). Any pointers (even minor modifications to the code below) would be greatly appreciated!

from bokeh.objects import Plot, DataRange1d, LinearAxis, ColumnDataSource, Glyph, Grid, Legend

from bokeh.widgetobjects import VBox,

from bokeh.glyphs import Patch, Line, Text

from bokeh.document import Document

from bokeh.session import Session

source = ColumnDataSource(data=dict(

x = [1, 2, 3],

y = [0, 10, 100]

))

xdr = DataRange1d(sources=[source.columns(“x”)])

ydr = DataRange1d(sources=[source.columns(“y”)])

plot = Plot(x_range=xdr, y_range=ydr, plot_width=800, plot_height=400)

line_f = Line(x=“x”, y=“y”, line_color=“blue”, line_width=2)

line_f_glyph = Glyph(data_source=source, xdata_range=xdr, ydata_range=ydr, glyph=line_f)

plot.renderers.append(line_f_glyph)

xaxis = LinearAxis(plot=plot)

plot.below.append(xaxis)

yaxis = LinearAxis(plot=plot)

plot.left.append(yaxis)

xgrid = Grid(plot=plot, dimension=0, ticker=xaxis.ticker)

ygrid = Grid(plot=plot, dimension=1, ticker=yaxis.ticker)

layout = VBox(children=[plot])

document.add(layout)

Josh

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/CAD4ivxX6gXsWaVTvQ_dcUjdnqWhfyYDF23kR%3DoTGsWvBtuqmSw%40mail.gmail.com.

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

Josh,

Presentation tomorrow => priority bump.

We spent some time exploring and found that you should actually be able to achieve the functionality you wanted in the first place!

In the widget callback function update_data, you should be able to call plot.x_range.factors = [‘arbitrary’, ‘new’, ‘factors’]

If you post the relevant portion of the code you are working on I can provide more accurate guidance; in the meantime I will clean up and post an example of this behavior.

Thanks for your patience,

Karan

···

On Wed, Aug 27, 2014 at 3:44 PM, Josh Wasserstein [email protected] wrote:

Thanks Karan. That makes sense. For now, I am just hoping to pitch the use of Bokeh in my team in a presentation tomorrow that includes a web front end that pulls data from a database ( wish me luck! :))

So just for me to get this running for now: If I have an image that is 800*600. How should I make the call to image_rgba?

For a quick demo, I have tried:

f = plt.figure(figsize=(12,6))

ax = f.add_subplot(111)

ax.plot([1,2,3,4])

plt.savefig(‘temp.png’)

import matplotlib.image as mpimg

image = mpimg.imread(‘temp.png’)

plot = image_rgba(image, x=0, y=0, dw=image.shape[0], dh=image.shape[1])

but I get:

RunTimeError:Columns need to be 1D (image is not)

Josh

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/CAD4ivxWhv1_Ym0z8NSn%2BXMJSMHKWBgSRxanErT14DTcna-96vQ%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 2:26 PM, Karan Dodia [email protected] wrote:

*> *can I use matplotlib to render a figure as a bitmap and then use some Bokeh widget to display it within an HBox VBox, or equivalent?

Short answer: yes. Disclaimer: this is a terrible idea; a 4th-class solution at best.

If you need something by the end of this week, here’s what you could do:

Render your MPL plot as a bitmap, and then use Bokeh’s image_rgba glyph to render it in an appropriately-sized Bokeh plot. I would also suggest turning off the plot title, axes, and tools to remove visual clutter. Then the widget—as in the taylor_server example—can be bound to a function to update the MPL plot, re-render to bitmap, load into image_rgba, etc.

This should work in theory, although I would again strongly hazard against using this method.

We the Bokeh team are constantly trying to strike a balance between closing off issues for smaller use-cases like this one and developing larger features to broaden Bokeh’s capabilities, but it’s clear that this can be bumped in priority.

Regards,

Karan

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/CAOvoNRQawtOc8f35WB_xNj3R0HmqOHXj-kxQUDHuDSF6Z-iMAw%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 12:48 PM, Josh Wasserstein [email protected] wrote:

Thanks Karan. You are correct. That’s exactly what I am looking for. I guess that there is no way to do this now. Would it be possible to have the bar plot come from matplotlib? (perhaps rendered as a bitmap). Is this something that Bokeh supports?

More generally, and I understand that this departs from the original question, can I use matplotlib to render a figure as a bitmap and then use some Bokeh widget to display it within an HBox VBox, or equivalent?

Josh

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/CAD4ivxUDCTyEJHDMZohAZa4sP_7Vu-f2CJON%2BVYgsDU5AdUr4g%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 12:18 PM, Karan Dodia [email protected] wrote:

Hello Josh,

It seems like you are trying to set up a categorical x-axis; am I correct in assuming that?

Unfortunately Bokeh does not support changing categorical axes at the moment; there is an open issue to track this behavior, and a related gist I’ve written up that demonstrates a code snippet that should work (but doesn’t currently).

I’ll make a note to ping you if I can resolve this in the near future.

Thanks!

Karan

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].

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

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAOvoNRQXa3b1W5NvBbkQgWwAaRauH71%2Bf2v87OK0Mg_mkLJNKw%40mail.gmail.com.

On Wed, Aug 27, 2014 at 10:56 AM, Josh Wasserstein [email protected] wrote:

Hi,

I am trying to build a document an example similar in spirit to taylor_server.py but with a bar chart instead (rather than a regular line plot). Assuming that my data is, for example:

labels = [‘foo’, bar’]

values = [-1, -2]

What changes specifically do I need to make?

The original taylor_server.py has roughly the following code to create the plot (ignoring the other widgets for now). Any pointers (even minor modifications to the code below) would be greatly appreciated!

from bokeh.objects import Plot, DataRange1d, LinearAxis, ColumnDataSource, Glyph, Grid, Legend

from bokeh.widgetobjects import VBox,

from bokeh.glyphs import Patch, Line, Text

from bokeh.document import Document

from bokeh.session import Session

source = ColumnDataSource(data=dict(

x = [1, 2, 3],

y = [0, 10, 100]

))

xdr = DataRange1d(sources=[source.columns(“x”)])

ydr = DataRange1d(sources=[source.columns(“y”)])

plot = Plot(x_range=xdr, y_range=ydr, plot_width=800, plot_height=400)

line_f = Line(x=“x”, y=“y”, line_color=“blue”, line_width=2)

line_f_glyph = Glyph(data_source=source, xdata_range=xdr, ydata_range=ydr, glyph=line_f)

plot.renderers.append(line_f_glyph)

xaxis = LinearAxis(plot=plot)

plot.below.append(xaxis)

yaxis = LinearAxis(plot=plot)

plot.left.append(yaxis)

xgrid = Grid(plot=plot, dimension=0, ticker=xaxis.ticker)

ygrid = Grid(plot=plot, dimension=1, ticker=yaxis.ticker)

layout = VBox(children=[plot])

document.add(layout)

Josh

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/CAD4ivxX6gXsWaVTvQ_dcUjdnqWhfyYDF23kR%3DoTGsWvBtuqmSw%40mail.gmail.com.

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

Thanks a lot Karan!

I am working on it right now. I will let you know if I have any problems. Greatly appreciate it. I have no doubt everyone is going to like this.

Josh

···

On Wed, Aug 27, 2014 at 6:31 PM, Karan Dodia [email protected] wrote:

Josh,

Presentation tomorrow => priority bump.

We spent some time exploring and found that you should actually be able to achieve the functionality you wanted in the first place!

In the widget callback function update_data, you should be able to call plot.x_range.factors = [‘arbitrary’, ‘new’, ‘factors’]

If you post the relevant portion of the code you are working on I can provide more accurate guidance; in the meantime I will clean up and post an example of this behavior.

Thanks for your patience,

Karan

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/CAOvoNRQe2tPq4CK9o3z0n4KZCKs14LeDifdArNxGzi8uttkW1w%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 3:44 PM, Josh Wasserstein [email protected] wrote:

Thanks Karan. That makes sense. For now, I am just hoping to pitch the use of Bokeh in my team in a presentation tomorrow that includes a web front end that pulls data from a database ( wish me luck! :))

So just for me to get this running for now: If I have an image that is 800*600. How should I make the call to image_rgba?

For a quick demo, I have tried:

f = plt.figure(figsize=(12,6))

ax = f.add_subplot(111)

ax.plot([1,2,3,4])

plt.savefig(‘temp.png’)

import matplotlib.image as mpimg

image = mpimg.imread(‘temp.png’)

plot = image_rgba(image, x=0, y=0, dw=image.shape[0], dh=image.shape[1])

but I get:

RunTimeError:Columns need to be 1D (image is not)

Josh

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/CAD4ivxWhv1_Ym0z8NSn%2BXMJSMHKWBgSRxanErT14DTcna-96vQ%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 2:26 PM, Karan Dodia [email protected] wrote:

*> *can I use matplotlib to render a figure as a bitmap and then use some Bokeh widget to display it within an HBox VBox, or equivalent?

Short answer: yes. Disclaimer: this is a terrible idea; a 4th-class solution at best.

If you need something by the end of this week, here’s what you could do:

Render your MPL plot as a bitmap, and then use Bokeh’s image_rgba glyph to render it in an appropriately-sized Bokeh plot. I would also suggest turning off the plot title, axes, and tools to remove visual clutter. Then the widget—as in the taylor_server example—can be bound to a function to update the MPL plot, re-render to bitmap, load into image_rgba, etc.

This should work in theory, although I would again strongly hazard against using this method.

We the Bokeh team are constantly trying to strike a balance between closing off issues for smaller use-cases like this one and developing larger features to broaden Bokeh’s capabilities, but it’s clear that this can be bumped in priority.

Regards,

Karan

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/CAOvoNRQawtOc8f35WB_xNj3R0HmqOHXj-kxQUDHuDSF6Z-iMAw%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 12:48 PM, Josh Wasserstein [email protected] wrote:

Thanks Karan. You are correct. That’s exactly what I am looking for. I guess that there is no way to do this now. Would it be possible to have the bar plot come from matplotlib? (perhaps rendered as a bitmap). Is this something that Bokeh supports?

More generally, and I understand that this departs from the original question, can I use matplotlib to render a figure as a bitmap and then use some Bokeh widget to display it within an HBox VBox, or equivalent?

Josh

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/CAD4ivxUDCTyEJHDMZohAZa4sP_7Vu-f2CJON%2BVYgsDU5AdUr4g%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 12:18 PM, Karan Dodia [email protected] wrote:

Hello Josh,

It seems like you are trying to set up a categorical x-axis; am I correct in assuming that?

Unfortunately Bokeh does not support changing categorical axes at the moment; there is an open issue to track this behavior, and a related gist I’ve written up that demonstrates a code snippet that should work (but doesn’t currently).

I’ll make a note to ping you if I can resolve this in the near future.

Thanks!

Karan

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].

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

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAOvoNRQXa3b1W5NvBbkQgWwAaRauH71%2Bf2v87OK0Mg_mkLJNKw%40mail.gmail.com.

On Wed, Aug 27, 2014 at 10:56 AM, Josh Wasserstein [email protected] wrote:

Hi,

I am trying to build a document an example similar in spirit to taylor_server.py but with a bar chart instead (rather than a regular line plot). Assuming that my data is, for example:

labels = [‘foo’, bar’]

values = [-1, -2]

What changes specifically do I need to make?

The original taylor_server.py has roughly the following code to create the plot (ignoring the other widgets for now). Any pointers (even minor modifications to the code below) would be greatly appreciated!

from bokeh.objects import Plot, DataRange1d, LinearAxis, ColumnDataSource, Glyph, Grid, Legend

from bokeh.widgetobjects import VBox,

from bokeh.glyphs import Patch, Line, Text

from bokeh.document import Document

from bokeh.session import Session

source = ColumnDataSource(data=dict(

x = [1, 2, 3],

y = [0, 10, 100]

))

xdr = DataRange1d(sources=[source.columns(“x”)])

ydr = DataRange1d(sources=[source.columns(“y”)])

plot = Plot(x_range=xdr, y_range=ydr, plot_width=800, plot_height=400)

line_f = Line(x=“x”, y=“y”, line_color=“blue”, line_width=2)

line_f_glyph = Glyph(data_source=source, xdata_range=xdr, ydata_range=ydr, glyph=line_f)

plot.renderers.append(line_f_glyph)

xaxis = LinearAxis(plot=plot)

plot.below.append(xaxis)

yaxis = LinearAxis(plot=plot)

plot.left.append(yaxis)

xgrid = Grid(plot=plot, dimension=0, ticker=xaxis.ticker)

ygrid = Grid(plot=plot, dimension=1, ticker=yaxis.ticker)

layout = VBox(children=[plot])

document.add(layout)

Josh

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/CAD4ivxX6gXsWaVTvQ_dcUjdnqWhfyYDF23kR%3DoTGsWvBtuqmSw%40mail.gmail.com.

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

Karan,

Just letting you know that for reasons other than ones I started above, I built a different app using three widgets: Select, Plot (regular numerical ranges), and TextInput.

Everything seems to be working great.

One quick question, is there any way to add a bit of extra spacing between widgets within HBox or VBox?

Josh

···

On Wed, Aug 27, 2014 at 7:57 PM, Josh Wasserstein [email protected] wrote:

Thanks a lot Karan!

I am working on it right now. I will let you know if I have any problems. Greatly appreciate it. I have no doubt everyone is going to like this.

Josh

On Wed, Aug 27, 2014 at 6:31 PM, Karan Dodia [email protected] wrote:

Josh,

Presentation tomorrow => priority bump.

We spent some time exploring and found that you should actually be able to achieve the functionality you wanted in the first place!

In the widget callback function update_data, you should be able to call plot.x_range.factors = [‘arbitrary’, ‘new’, ‘factors’]

If you post the relevant portion of the code you are working on I can provide more accurate guidance; in the meantime I will clean up and post an example of this behavior.

Thanks for your patience,

Karan

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/CAOvoNRQe2tPq4CK9o3z0n4KZCKs14LeDifdArNxGzi8uttkW1w%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 3:44 PM, Josh Wasserstein [email protected] wrote:

Thanks Karan. That makes sense. For now, I am just hoping to pitch the use of Bokeh in my team in a presentation tomorrow that includes a web front end that pulls data from a database ( wish me luck! :))

So just for me to get this running for now: If I have an image that is 800*600. How should I make the call to image_rgba?

For a quick demo, I have tried:

f = plt.figure(figsize=(12,6))

ax = f.add_subplot(111)

ax.plot([1,2,3,4])

plt.savefig(‘temp.png’)

import matplotlib.image as mpimg

image = mpimg.imread(‘temp.png’)

plot = image_rgba(image, x=0, y=0, dw=image.shape[0], dh=image.shape[1])

but I get:

RunTimeError:Columns need to be 1D (image is not)

Josh

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/CAD4ivxWhv1_Ym0z8NSn%2BXMJSMHKWBgSRxanErT14DTcna-96vQ%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 2:26 PM, Karan Dodia [email protected] wrote:

*> *can I use matplotlib to render a figure as a bitmap and then use some Bokeh widget to display it within an HBox VBox, or equivalent?

Short answer: yes. Disclaimer: this is a terrible idea; a 4th-class solution at best.

If you need something by the end of this week, here’s what you could do:

Render your MPL plot as a bitmap, and then use Bokeh’s image_rgba glyph to render it in an appropriately-sized Bokeh plot. I would also suggest turning off the plot title, axes, and tools to remove visual clutter. Then the widget—as in the taylor_server example—can be bound to a function to update the MPL plot, re-render to bitmap, load into image_rgba, etc.

This should work in theory, although I would again strongly hazard against using this method.

We the Bokeh team are constantly trying to strike a balance between closing off issues for smaller use-cases like this one and developing larger features to broaden Bokeh’s capabilities, but it’s clear that this can be bumped in priority.

Regards,

Karan

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/CAOvoNRQawtOc8f35WB_xNj3R0HmqOHXj-kxQUDHuDSF6Z-iMAw%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 12:48 PM, Josh Wasserstein [email protected] wrote:

Thanks Karan. You are correct. That’s exactly what I am looking for. I guess that there is no way to do this now. Would it be possible to have the bar plot come from matplotlib? (perhaps rendered as a bitmap). Is this something that Bokeh supports?

More generally, and I understand that this departs from the original question, can I use matplotlib to render a figure as a bitmap and then use some Bokeh widget to display it within an HBox VBox, or equivalent?

Josh

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/CAD4ivxUDCTyEJHDMZohAZa4sP_7Vu-f2CJON%2BVYgsDU5AdUr4g%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 12:18 PM, Karan Dodia [email protected] wrote:

Hello Josh,

It seems like you are trying to set up a categorical x-axis; am I correct in assuming that?

Unfortunately Bokeh does not support changing categorical axes at the moment; there is an open issue to track this behavior, and a related gist I’ve written up that demonstrates a code snippet that should work (but doesn’t currently).

I’ll make a note to ping you if I can resolve this in the near future.

Thanks!

Karan

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].

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

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAOvoNRQXa3b1W5NvBbkQgWwAaRauH71%2Bf2v87OK0Mg_mkLJNKw%40mail.gmail.com.

On Wed, Aug 27, 2014 at 10:56 AM, Josh Wasserstein [email protected] wrote:

Hi,

I am trying to build a document an example similar in spirit to taylor_server.py but with a bar chart instead (rather than a regular line plot). Assuming that my data is, for example:

labels = [‘foo’, bar’]

values = [-1, -2]

What changes specifically do I need to make?

The original taylor_server.py has roughly the following code to create the plot (ignoring the other widgets for now). Any pointers (even minor modifications to the code below) would be greatly appreciated!

from bokeh.objects import Plot, DataRange1d, LinearAxis, ColumnDataSource, Glyph, Grid, Legend

from bokeh.widgetobjects import VBox,

from bokeh.glyphs import Patch, Line, Text

from bokeh.document import Document

from bokeh.session import Session

source = ColumnDataSource(data=dict(

x = [1, 2, 3],

y = [0, 10, 100]

))

xdr = DataRange1d(sources=[source.columns(“x”)])

ydr = DataRange1d(sources=[source.columns(“y”)])

plot = Plot(x_range=xdr, y_range=ydr, plot_width=800, plot_height=400)

line_f = Line(x=“x”, y=“y”, line_color=“blue”, line_width=2)

line_f_glyph = Glyph(data_source=source, xdata_range=xdr, ydata_range=ydr, glyph=line_f)

plot.renderers.append(line_f_glyph)

xaxis = LinearAxis(plot=plot)

plot.below.append(xaxis)

yaxis = LinearAxis(plot=plot)

plot.left.append(yaxis)

xgrid = Grid(plot=plot, dimension=0, ticker=xaxis.ticker)

ygrid = Grid(plot=plot, dimension=1, ticker=yaxis.ticker)

layout = VBox(children=[plot])

document.add(layout)

Josh

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/CAD4ivxX6gXsWaVTvQ_dcUjdnqWhfyYDF23kR%3DoTGsWvBtuqmSw%40mail.gmail.com.

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

Also, since we are at it, is there any way to control the orientation of the Y-label on a plot? I couldn’t find a Plot property that sets this

Josh

···

On Wed, Aug 27, 2014 at 9:30 PM, Josh Wasserstein [email protected] wrote:

Karan,

Just letting you know that for reasons other than ones I started above, I built a different app using three widgets: Select, Plot (regular numerical ranges), and TextInput.

Everything seems to be working great.

One quick question, is there any way to add a bit of extra spacing between widgets within HBox or VBox?

Josh

On Wed, Aug 27, 2014 at 7:57 PM, Josh Wasserstein [email protected] wrote:

Thanks a lot Karan!

I am working on it right now. I will let you know if I have any problems. Greatly appreciate it. I have no doubt everyone is going to like this.

Josh

On Wed, Aug 27, 2014 at 6:31 PM, Karan Dodia [email protected] wrote:

Josh,

Presentation tomorrow => priority bump.

We spent some time exploring and found that you should actually be able to achieve the functionality you wanted in the first place!

In the widget callback function update_data, you should be able to call plot.x_range.factors = [‘arbitrary’, ‘new’, ‘factors’]

If you post the relevant portion of the code you are working on I can provide more accurate guidance; in the meantime I will clean up and post an example of this behavior.

Thanks for your patience,

Karan

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/CAOvoNRQe2tPq4CK9o3z0n4KZCKs14LeDifdArNxGzi8uttkW1w%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 3:44 PM, Josh Wasserstein [email protected] wrote:

Thanks Karan. That makes sense. For now, I am just hoping to pitch the use of Bokeh in my team in a presentation tomorrow that includes a web front end that pulls data from a database ( wish me luck! :))

So just for me to get this running for now: If I have an image that is 800*600. How should I make the call to image_rgba?

For a quick demo, I have tried:

f = plt.figure(figsize=(12,6))

ax = f.add_subplot(111)

ax.plot([1,2,3,4])

plt.savefig(‘temp.png’)

import matplotlib.image as mpimg

image = mpimg.imread(‘temp.png’)

plot = image_rgba(image, x=0, y=0, dw=image.shape[0], dh=image.shape[1])

but I get:

RunTimeError:Columns need to be 1D (image is not)

Josh

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/CAD4ivxWhv1_Ym0z8NSn%2BXMJSMHKWBgSRxanErT14DTcna-96vQ%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 2:26 PM, Karan Dodia [email protected] wrote:

*> *can I use matplotlib to render a figure as a bitmap and then use some Bokeh widget to display it within an HBox VBox, or equivalent?

Short answer: yes. Disclaimer: this is a terrible idea; a 4th-class solution at best.

If you need something by the end of this week, here’s what you could do:

Render your MPL plot as a bitmap, and then use Bokeh’s image_rgba glyph to render it in an appropriately-sized Bokeh plot. I would also suggest turning off the plot title, axes, and tools to remove visual clutter. Then the widget—as in the taylor_server example—can be bound to a function to update the MPL plot, re-render to bitmap, load into image_rgba, etc.

This should work in theory, although I would again strongly hazard against using this method.

We the Bokeh team are constantly trying to strike a balance between closing off issues for smaller use-cases like this one and developing larger features to broaden Bokeh’s capabilities, but it’s clear that this can be bumped in priority.

Regards,

Karan

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/CAOvoNRQawtOc8f35WB_xNj3R0HmqOHXj-kxQUDHuDSF6Z-iMAw%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 12:48 PM, Josh Wasserstein [email protected] wrote:

Thanks Karan. You are correct. That’s exactly what I am looking for. I guess that there is no way to do this now. Would it be possible to have the bar plot come from matplotlib? (perhaps rendered as a bitmap). Is this something that Bokeh supports?

More generally, and I understand that this departs from the original question, can I use matplotlib to render a figure as a bitmap and then use some Bokeh widget to display it within an HBox VBox, or equivalent?

Josh

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/CAD4ivxUDCTyEJHDMZohAZa4sP_7Vu-f2CJON%2BVYgsDU5AdUr4g%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 12:18 PM, Karan Dodia [email protected] wrote:

Hello Josh,

It seems like you are trying to set up a categorical x-axis; am I correct in assuming that?

Unfortunately Bokeh does not support changing categorical axes at the moment; there is an open issue to track this behavior, and a related gist I’ve written up that demonstrates a code snippet that should work (but doesn’t currently).

I’ll make a note to ping you if I can resolve this in the near future.

Thanks!

Karan

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].

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

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAOvoNRQXa3b1W5NvBbkQgWwAaRauH71%2Bf2v87OK0Mg_mkLJNKw%40mail.gmail.com.

On Wed, Aug 27, 2014 at 10:56 AM, Josh Wasserstein [email protected] wrote:

Hi,

I am trying to build a document an example similar in spirit to taylor_server.py but with a bar chart instead (rather than a regular line plot). Assuming that my data is, for example:

labels = [‘foo’, bar’]

values = [-1, -2]

What changes specifically do I need to make?

The original taylor_server.py has roughly the following code to create the plot (ignoring the other widgets for now). Any pointers (even minor modifications to the code below) would be greatly appreciated!

from bokeh.objects import Plot, DataRange1d, LinearAxis, ColumnDataSource, Glyph, Grid, Legend

from bokeh.widgetobjects import VBox,

from bokeh.glyphs import Patch, Line, Text

from bokeh.document import Document

from bokeh.session import Session

source = ColumnDataSource(data=dict(

x = [1, 2, 3],

y = [0, 10, 100]

))

xdr = DataRange1d(sources=[source.columns(“x”)])

ydr = DataRange1d(sources=[source.columns(“y”)])

plot = Plot(x_range=xdr, y_range=ydr, plot_width=800, plot_height=400)

line_f = Line(x=“x”, y=“y”, line_color=“blue”, line_width=2)

line_f_glyph = Glyph(data_source=source, xdata_range=xdr, ydata_range=ydr, glyph=line_f)

plot.renderers.append(line_f_glyph)

xaxis = LinearAxis(plot=plot)

plot.below.append(xaxis)

yaxis = LinearAxis(plot=plot)

plot.left.append(yaxis)

xgrid = Grid(plot=plot, dimension=0, ticker=xaxis.ticker)

ygrid = Grid(plot=plot, dimension=1, ticker=yaxis.ticker)

layout = VBox(children=[plot])

document.add(layout)

Josh

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/CAD4ivxX6gXsWaVTvQ_dcUjdnqWhfyYDF23kR%3DoTGsWvBtuqmSw%40mail.gmail.com.

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

Try with: major_label_orientation.

Some examples (but you have to use it with the yaxis for y-labels:

Hope it helps!

···

On Wed, Aug 27, 2014 at 11:11 PM, Josh Wasserstein [email protected] wrote:

Also, since we are at it, is there any way to control the orientation of the Y-label on a plot? I couldn’t find a Plot property that sets this

Josh

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/CAD4ivxU2ZaJjRHm_hKb16FQM8K%3DD5eiTxMtpUwixdGLH7dJt0A%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 9:30 PM, Josh Wasserstein [email protected] wrote:

Karan,

Just letting you know that for reasons other than ones I started above, I built a different app using three widgets: Select, Plot (regular numerical ranges), and TextInput.

Everything seems to be working great.

One quick question, is there any way to add a bit of extra spacing between widgets within HBox or VBox?

Josh

On Wed, Aug 27, 2014 at 7:57 PM, Josh Wasserstein [email protected] wrote:

Thanks a lot Karan!

I am working on it right now. I will let you know if I have any problems. Greatly appreciate it. I have no doubt everyone is going to like this.

Josh

On Wed, Aug 27, 2014 at 6:31 PM, Karan Dodia [email protected] wrote:

Josh,

Presentation tomorrow => priority bump.

We spent some time exploring and found that you should actually be able to achieve the functionality you wanted in the first place!

In the widget callback function update_data, you should be able to call plot.x_range.factors = [‘arbitrary’, ‘new’, ‘factors’]

If you post the relevant portion of the code you are working on I can provide more accurate guidance; in the meantime I will clean up and post an example of this behavior.

Thanks for your patience,

Karan

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/CAOvoNRQe2tPq4CK9o3z0n4KZCKs14LeDifdArNxGzi8uttkW1w%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 3:44 PM, Josh Wasserstein [email protected] wrote:

Thanks Karan. That makes sense. For now, I am just hoping to pitch the use of Bokeh in my team in a presentation tomorrow that includes a web front end that pulls data from a database ( wish me luck! :))

So just for me to get this running for now: If I have an image that is 800*600. How should I make the call to image_rgba?

For a quick demo, I have tried:

f = plt.figure(figsize=(12,6))

ax = f.add_subplot(111)

ax.plot([1,2,3,4])

plt.savefig(‘temp.png’)

import matplotlib.image as mpimg

image = mpimg.imread(‘temp.png’)

plot = image_rgba(image, x=0, y=0, dw=image.shape[0], dh=image.shape[1])

but I get:

RunTimeError:Columns need to be 1D (image is not)

Josh

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/CAD4ivxWhv1_Ym0z8NSn%2BXMJSMHKWBgSRxanErT14DTcna-96vQ%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 2:26 PM, Karan Dodia [email protected] wrote:

*> *can I use matplotlib to render a figure as a bitmap and then use some Bokeh widget to display it within an HBox VBox, or equivalent?

Short answer: yes. Disclaimer: this is a terrible idea; a 4th-class solution at best.

If you need something by the end of this week, here’s what you could do:

Render your MPL plot as a bitmap, and then use Bokeh’s image_rgba glyph to render it in an appropriately-sized Bokeh plot. I would also suggest turning off the plot title, axes, and tools to remove visual clutter. Then the widget—as in the taylor_server example—can be bound to a function to update the MPL plot, re-render to bitmap, load into image_rgba, etc.

This should work in theory, although I would again strongly hazard against using this method.

We the Bokeh team are constantly trying to strike a balance between closing off issues for smaller use-cases like this one and developing larger features to broaden Bokeh’s capabilities, but it’s clear that this can be bumped in priority.

Regards,

Karan

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/CAOvoNRQawtOc8f35WB_xNj3R0HmqOHXj-kxQUDHuDSF6Z-iMAw%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 12:48 PM, Josh Wasserstein [email protected] wrote:

Thanks Karan. You are correct. That’s exactly what I am looking for. I guess that there is no way to do this now. Would it be possible to have the bar plot come from matplotlib? (perhaps rendered as a bitmap). Is this something that Bokeh supports?

More generally, and I understand that this departs from the original question, can I use matplotlib to render a figure as a bitmap and then use some Bokeh widget to display it within an HBox VBox, or equivalent?

Josh

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/CAD4ivxUDCTyEJHDMZohAZa4sP_7Vu-f2CJON%2BVYgsDU5AdUr4g%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 12:18 PM, Karan Dodia [email protected] wrote:

Hello Josh,

It seems like you are trying to set up a categorical x-axis; am I correct in assuming that?

Unfortunately Bokeh does not support changing categorical axes at the moment; there is an open issue to track this behavior, and a related gist I’ve written up that demonstrates a code snippet that should work (but doesn’t currently).

I’ll make a note to ping you if I can resolve this in the near future.

Thanks!

Karan

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].

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

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAOvoNRQXa3b1W5NvBbkQgWwAaRauH71%2Bf2v87OK0Mg_mkLJNKw%40mail.gmail.com.

On Wed, Aug 27, 2014 at 10:56 AM, Josh Wasserstein [email protected] wrote:

Hi,

I am trying to build a document an example similar in spirit to taylor_server.py but with a bar chart instead (rather than a regular line plot). Assuming that my data is, for example:

labels = [‘foo’, bar’]

values = [-1, -2]

What changes specifically do I need to make?

The original taylor_server.py has roughly the following code to create the plot (ignoring the other widgets for now). Any pointers (even minor modifications to the code below) would be greatly appreciated!

from bokeh.objects import Plot, DataRange1d, LinearAxis, ColumnDataSource, Glyph, Grid, Legend

from bokeh.widgetobjects import VBox,

from bokeh.glyphs import Patch, Line, Text

from bokeh.document import Document

from bokeh.session import Session

source = ColumnDataSource(data=dict(

x = [1, 2, 3],

y = [0, 10, 100]

))

xdr = DataRange1d(sources=[source.columns(“x”)])

ydr = DataRange1d(sources=[source.columns(“y”)])

plot = Plot(x_range=xdr, y_range=ydr, plot_width=800, plot_height=400)

line_f = Line(x=“x”, y=“y”, line_color=“blue”, line_width=2)

line_f_glyph = Glyph(data_source=source, xdata_range=xdr, ydata_range=ydr, glyph=line_f)

plot.renderers.append(line_f_glyph)

xaxis = LinearAxis(plot=plot)

plot.below.append(xaxis)

yaxis = LinearAxis(plot=plot)

plot.left.append(yaxis)

xgrid = Grid(plot=plot, dimension=0, ticker=xaxis.ticker)

ygrid = Grid(plot=plot, dimension=1, ticker=yaxis.ticker)

layout = VBox(children=[plot])

document.add(layout)

Josh

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/CAD4ivxX6gXsWaVTvQ_dcUjdnqWhfyYDF23kR%3DoTGsWvBtuqmSw%40mail.gmail.com.

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

Awesome. Thanks Damian!

Josh

···

On Wed, Aug 27, 2014 at 10:27 PM, Damian Avila [email protected] wrote:

Try with: major_label_orientation.

Some examples (but you have to use it with the yaxis for y-labels:

Hope it helps!

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/CAM9Ly3HNuxEqmTWnmgkMf5VH5eO09_kJPz2iHHfmcysRpbP0PA%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 11:11 PM, Josh Wasserstein [email protected] wrote:

Also, since we are at it, is there any way to control the orientation of the Y-label on a plot? I couldn’t find a Plot property that sets this

Josh

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/CAD4ivxU2ZaJjRHm_hKb16FQM8K%3DD5eiTxMtpUwixdGLH7dJt0A%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 9:30 PM, Josh Wasserstein [email protected] wrote:

Karan,

Just letting you know that for reasons other than ones I started above, I built a different app using three widgets: Select, Plot (regular numerical ranges), and TextInput.

Everything seems to be working great.

One quick question, is there any way to add a bit of extra spacing between widgets within HBox or VBox?

Josh

On Wed, Aug 27, 2014 at 7:57 PM, Josh Wasserstein [email protected] wrote:

Thanks a lot Karan!

I am working on it right now. I will let you know if I have any problems. Greatly appreciate it. I have no doubt everyone is going to like this.

Josh

On Wed, Aug 27, 2014 at 6:31 PM, Karan Dodia [email protected] wrote:

Josh,

Presentation tomorrow => priority bump.

We spent some time exploring and found that you should actually be able to achieve the functionality you wanted in the first place!

In the widget callback function update_data, you should be able to call plot.x_range.factors = [‘arbitrary’, ‘new’, ‘factors’]

If you post the relevant portion of the code you are working on I can provide more accurate guidance; in the meantime I will clean up and post an example of this behavior.

Thanks for your patience,

Karan

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/CAOvoNRQe2tPq4CK9o3z0n4KZCKs14LeDifdArNxGzi8uttkW1w%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 3:44 PM, Josh Wasserstein [email protected] wrote:

Thanks Karan. That makes sense. For now, I am just hoping to pitch the use of Bokeh in my team in a presentation tomorrow that includes a web front end that pulls data from a database ( wish me luck! :))

So just for me to get this running for now: If I have an image that is 800*600. How should I make the call to image_rgba?

For a quick demo, I have tried:

f = plt.figure(figsize=(12,6))

ax = f.add_subplot(111)

ax.plot([1,2,3,4])

plt.savefig(‘temp.png’)

import matplotlib.image as mpimg

image = mpimg.imread(‘temp.png’)

plot = image_rgba(image, x=0, y=0, dw=image.shape[0], dh=image.shape[1])

but I get:

RunTimeError:Columns need to be 1D (image is not)

Josh

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/CAD4ivxWhv1_Ym0z8NSn%2BXMJSMHKWBgSRxanErT14DTcna-96vQ%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 2:26 PM, Karan Dodia [email protected] wrote:

*> *can I use matplotlib to render a figure as a bitmap and then use some Bokeh widget to display it within an HBox VBox, or equivalent?

Short answer: yes. Disclaimer: this is a terrible idea; a 4th-class solution at best.

If you need something by the end of this week, here’s what you could do:

Render your MPL plot as a bitmap, and then use Bokeh’s image_rgba glyph to render it in an appropriately-sized Bokeh plot. I would also suggest turning off the plot title, axes, and tools to remove visual clutter. Then the widget—as in the taylor_server example—can be bound to a function to update the MPL plot, re-render to bitmap, load into image_rgba, etc.

This should work in theory, although I would again strongly hazard against using this method.

We the Bokeh team are constantly trying to strike a balance between closing off issues for smaller use-cases like this one and developing larger features to broaden Bokeh’s capabilities, but it’s clear that this can be bumped in priority.

Regards,

Karan

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/CAOvoNRQawtOc8f35WB_xNj3R0HmqOHXj-kxQUDHuDSF6Z-iMAw%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 12:48 PM, Josh Wasserstein [email protected] wrote:

Thanks Karan. You are correct. That’s exactly what I am looking for. I guess that there is no way to do this now. Would it be possible to have the bar plot come from matplotlib? (perhaps rendered as a bitmap). Is this something that Bokeh supports?

More generally, and I understand that this departs from the original question, can I use matplotlib to render a figure as a bitmap and then use some Bokeh widget to display it within an HBox VBox, or equivalent?

Josh

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/CAD4ivxUDCTyEJHDMZohAZa4sP_7Vu-f2CJON%2BVYgsDU5AdUr4g%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 12:18 PM, Karan Dodia [email protected] wrote:

Hello Josh,

It seems like you are trying to set up a categorical x-axis; am I correct in assuming that?

Unfortunately Bokeh does not support changing categorical axes at the moment; there is an open issue to track this behavior, and a related gist I’ve written up that demonstrates a code snippet that should work (but doesn’t currently).

I’ll make a note to ping you if I can resolve this in the near future.

Thanks!

Karan

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].

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

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAOvoNRQXa3b1W5NvBbkQgWwAaRauH71%2Bf2v87OK0Mg_mkLJNKw%40mail.gmail.com.

On Wed, Aug 27, 2014 at 10:56 AM, Josh Wasserstein [email protected] wrote:

Hi,

I am trying to build a document an example similar in spirit to taylor_server.py but with a bar chart instead (rather than a regular line plot). Assuming that my data is, for example:

labels = [‘foo’, bar’]

values = [-1, -2]

What changes specifically do I need to make?

The original taylor_server.py has roughly the following code to create the plot (ignoring the other widgets for now). Any pointers (even minor modifications to the code below) would be greatly appreciated!

from bokeh.objects import Plot, DataRange1d, LinearAxis, ColumnDataSource, Glyph, Grid, Legend

from bokeh.widgetobjects import VBox,

from bokeh.glyphs import Patch, Line, Text

from bokeh.document import Document

from bokeh.session import Session

source = ColumnDataSource(data=dict(

x = [1, 2, 3],

y = [0, 10, 100]

))

xdr = DataRange1d(sources=[source.columns(“x”)])

ydr = DataRange1d(sources=[source.columns(“y”)])

plot = Plot(x_range=xdr, y_range=ydr, plot_width=800, plot_height=400)

line_f = Line(x=“x”, y=“y”, line_color=“blue”, line_width=2)

line_f_glyph = Glyph(data_source=source, xdata_range=xdr, ydata_range=ydr, glyph=line_f)

plot.renderers.append(line_f_glyph)

xaxis = LinearAxis(plot=plot)

plot.below.append(xaxis)

yaxis = LinearAxis(plot=plot)

plot.left.append(yaxis)

xgrid = Grid(plot=plot, dimension=0, ticker=xaxis.ticker)

ygrid = Grid(plot=plot, dimension=1, ticker=yaxis.ticker)

layout = VBox(children=[plot])

document.add(layout)

Josh

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/CAD4ivxX6gXsWaVTvQ_dcUjdnqWhfyYDF23kR%3DoTGsWvBtuqmSw%40mail.gmail.com.

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

Damian,

Unfortunately “major_label_orientation” rotates the tick labels, not the axis label.

Josh

···

On Wed, Aug 27, 2014 at 11:55 PM, Josh Wasserstein [email protected] wrote:

Josh

Awesome. Thanks Damian!

On Wed, Aug 27, 2014 at 10:27 PM, Damian Avila [email protected] wrote:

Try with: major_label_orientation.

Some examples (but you have to use it with the yaxis for y-labels:

Hope it helps!

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/CAM9Ly3HNuxEqmTWnmgkMf5VH5eO09_kJPz2iHHfmcysRpbP0PA%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 11:11 PM, Josh Wasserstein [email protected] wrote:

Also, since we are at it, is there any way to control the orientation of the Y-label on a plot? I couldn’t find a Plot property that sets this

Josh

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/CAD4ivxU2ZaJjRHm_hKb16FQM8K%3DD5eiTxMtpUwixdGLH7dJt0A%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 9:30 PM, Josh Wasserstein [email protected] wrote:

Karan,

Just letting you know that for reasons other than ones I started above, I built a different app using three widgets: Select, Plot (regular numerical ranges), and TextInput.

Everything seems to be working great.

One quick question, is there any way to add a bit of extra spacing between widgets within HBox or VBox?

Josh

On Wed, Aug 27, 2014 at 7:57 PM, Josh Wasserstein [email protected] wrote:

Thanks a lot Karan!

I am working on it right now. I will let you know if I have any problems. Greatly appreciate it. I have no doubt everyone is going to like this.

Josh

On Wed, Aug 27, 2014 at 6:31 PM, Karan Dodia [email protected] wrote:

Josh,

Presentation tomorrow => priority bump.

We spent some time exploring and found that you should actually be able to achieve the functionality you wanted in the first place!

In the widget callback function update_data, you should be able to call plot.x_range.factors = [‘arbitrary’, ‘new’, ‘factors’]

If you post the relevant portion of the code you are working on I can provide more accurate guidance; in the meantime I will clean up and post an example of this behavior.

Thanks for your patience,

Karan

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/CAOvoNRQe2tPq4CK9o3z0n4KZCKs14LeDifdArNxGzi8uttkW1w%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 3:44 PM, Josh Wasserstein [email protected] wrote:

Thanks Karan. That makes sense. For now, I am just hoping to pitch the use of Bokeh in my team in a presentation tomorrow that includes a web front end that pulls data from a database ( wish me luck! :))

So just for me to get this running for now: If I have an image that is 800*600. How should I make the call to image_rgba?

For a quick demo, I have tried:

f = plt.figure(figsize=(12,6))

ax = f.add_subplot(111)

ax.plot([1,2,3,4])

plt.savefig(‘temp.png’)

import matplotlib.image as mpimg

image = mpimg.imread(‘temp.png’)

plot = image_rgba(image, x=0, y=0, dw=image.shape[0], dh=image.shape[1])

but I get:

RunTimeError:Columns need to be 1D (image is not)

Josh

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/CAD4ivxWhv1_Ym0z8NSn%2BXMJSMHKWBgSRxanErT14DTcna-96vQ%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 2:26 PM, Karan Dodia [email protected] wrote:

*> *can I use matplotlib to render a figure as a bitmap and then use some Bokeh widget to display it within an HBox VBox, or equivalent?

Short answer: yes. Disclaimer: this is a terrible idea; a 4th-class solution at best.

If you need something by the end of this week, here’s what you could do:

Render your MPL plot as a bitmap, and then use Bokeh’s image_rgba glyph to render it in an appropriately-sized Bokeh plot. I would also suggest turning off the plot title, axes, and tools to remove visual clutter. Then the widget—as in the taylor_server example—can be bound to a function to update the MPL plot, re-render to bitmap, load into image_rgba, etc.

This should work in theory, although I would again strongly hazard against using this method.

We the Bokeh team are constantly trying to strike a balance between closing off issues for smaller use-cases like this one and developing larger features to broaden Bokeh’s capabilities, but it’s clear that this can be bumped in priority.

Regards,

Karan

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/CAOvoNRQawtOc8f35WB_xNj3R0HmqOHXj-kxQUDHuDSF6Z-iMAw%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 12:48 PM, Josh Wasserstein [email protected] wrote:

Thanks Karan. You are correct. That’s exactly what I am looking for. I guess that there is no way to do this now. Would it be possible to have the bar plot come from matplotlib? (perhaps rendered as a bitmap). Is this something that Bokeh supports?

More generally, and I understand that this departs from the original question, can I use matplotlib to render a figure as a bitmap and then use some Bokeh widget to display it within an HBox VBox, or equivalent?

Josh

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/CAD4ivxUDCTyEJHDMZohAZa4sP_7Vu-f2CJON%2BVYgsDU5AdUr4g%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 12:18 PM, Karan Dodia [email protected] wrote:

Hello Josh,

It seems like you are trying to set up a categorical x-axis; am I correct in assuming that?

Unfortunately Bokeh does not support changing categorical axes at the moment; there is an open issue to track this behavior, and a related gist I’ve written up that demonstrates a code snippet that should work (but doesn’t currently).

I’ll make a note to ping you if I can resolve this in the near future.

Thanks!

Karan

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].

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

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAOvoNRQXa3b1W5NvBbkQgWwAaRauH71%2Bf2v87OK0Mg_mkLJNKw%40mail.gmail.com.

On Wed, Aug 27, 2014 at 10:56 AM, Josh Wasserstein [email protected] wrote:

Hi,

I am trying to build a document an example similar in spirit to taylor_server.py but with a bar chart instead (rather than a regular line plot). Assuming that my data is, for example:

labels = [‘foo’, bar’]

values = [-1, -2]

What changes specifically do I need to make?

The original taylor_server.py has roughly the following code to create the plot (ignoring the other widgets for now). Any pointers (even minor modifications to the code below) would be greatly appreciated!

from bokeh.objects import Plot, DataRange1d, LinearAxis, ColumnDataSource, Glyph, Grid, Legend

from bokeh.widgetobjects import VBox,

from bokeh.glyphs import Patch, Line, Text

from bokeh.document import Document

from bokeh.session import Session

source = ColumnDataSource(data=dict(

x = [1, 2, 3],

y = [0, 10, 100]

))

xdr = DataRange1d(sources=[source.columns(“x”)])

ydr = DataRange1d(sources=[source.columns(“y”)])

plot = Plot(x_range=xdr, y_range=ydr, plot_width=800, plot_height=400)

line_f = Line(x=“x”, y=“y”, line_color=“blue”, line_width=2)

line_f_glyph = Glyph(data_source=source, xdata_range=xdr, ydata_range=ydr, glyph=line_f)

plot.renderers.append(line_f_glyph)

xaxis = LinearAxis(plot=plot)

plot.below.append(xaxis)

yaxis = LinearAxis(plot=plot)

plot.left.append(yaxis)

xgrid = Grid(plot=plot, dimension=0, ticker=xaxis.ticker)

ygrid = Grid(plot=plot, dimension=1, ticker=yaxis.ticker)

layout = VBox(children=[plot])

document.add(layout)

Josh

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/CAD4ivxX6gXsWaVTvQ_dcUjdnqWhfyYDF23kR%3DoTGsWvBtuqmSw%40mail.gmail.com.

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

oh… I misunderstood your question… we don’t support rotation of “title” label yet, I have opened an issue to request this feature: https://github.com/ContinuumIO/bokeh/issues/1085

Damian

···

On Thu, Aug 28, 2014 at 9:52 AM, Josh Wasserstein [email protected] wrote:

Damian,

Unfortunately “major_label_orientation” rotates the tick labels, not the axis label.

Josh

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/CAD4ivxVUMuZN-wexr2aXXKCRhzVTrPoHhnxsChuFE-NPaXRMnA%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 11:55 PM, Josh Wasserstein [email protected] wrote:

Josh

Awesome. Thanks Damian!

On Wed, Aug 27, 2014 at 10:27 PM, Damian Avila [email protected] wrote:

Try with: major_label_orientation.

Some examples (but you have to use it with the yaxis for y-labels:

Hope it helps!

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/CAM9Ly3HNuxEqmTWnmgkMf5VH5eO09_kJPz2iHHfmcysRpbP0PA%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 11:11 PM, Josh Wasserstein [email protected] wrote:

Also, since we are at it, is there any way to control the orientation of the Y-label on a plot? I couldn’t find a Plot property that sets this

Josh

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/CAD4ivxU2ZaJjRHm_hKb16FQM8K%3DD5eiTxMtpUwixdGLH7dJt0A%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 9:30 PM, Josh Wasserstein [email protected] wrote:

Karan,

Just letting you know that for reasons other than ones I started above, I built a different app using three widgets: Select, Plot (regular numerical ranges), and TextInput.

Everything seems to be working great.

One quick question, is there any way to add a bit of extra spacing between widgets within HBox or VBox?

Josh

On Wed, Aug 27, 2014 at 7:57 PM, Josh Wasserstein [email protected] wrote:

Thanks a lot Karan!

I am working on it right now. I will let you know if I have any problems. Greatly appreciate it. I have no doubt everyone is going to like this.

Josh

On Wed, Aug 27, 2014 at 6:31 PM, Karan Dodia [email protected] wrote:

Josh,

Presentation tomorrow => priority bump.

We spent some time exploring and found that you should actually be able to achieve the functionality you wanted in the first place!

In the widget callback function update_data, you should be able to call plot.x_range.factors = [‘arbitrary’, ‘new’, ‘factors’]

If you post the relevant portion of the code you are working on I can provide more accurate guidance; in the meantime I will clean up and post an example of this behavior.

Thanks for your patience,

Karan

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/CAOvoNRQe2tPq4CK9o3z0n4KZCKs14LeDifdArNxGzi8uttkW1w%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 3:44 PM, Josh Wasserstein [email protected] wrote:

Thanks Karan. That makes sense. For now, I am just hoping to pitch the use of Bokeh in my team in a presentation tomorrow that includes a web front end that pulls data from a database ( wish me luck! :))

So just for me to get this running for now: If I have an image that is 800*600. How should I make the call to image_rgba?

For a quick demo, I have tried:

f = plt.figure(figsize=(12,6))

ax = f.add_subplot(111)

ax.plot([1,2,3,4])

plt.savefig(‘temp.png’)

import matplotlib.image as mpimg

image = mpimg.imread(‘temp.png’)

plot = image_rgba(image, x=0, y=0, dw=image.shape[0], dh=image.shape[1])

but I get:

RunTimeError:Columns need to be 1D (image is not)

Josh

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/CAD4ivxWhv1_Ym0z8NSn%2BXMJSMHKWBgSRxanErT14DTcna-96vQ%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 2:26 PM, Karan Dodia [email protected] wrote:

*> *can I use matplotlib to render a figure as a bitmap and then use some Bokeh widget to display it within an HBox VBox, or equivalent?

Short answer: yes. Disclaimer: this is a terrible idea; a 4th-class solution at best.

If you need something by the end of this week, here’s what you could do:

Render your MPL plot as a bitmap, and then use Bokeh’s image_rgba glyph to render it in an appropriately-sized Bokeh plot. I would also suggest turning off the plot title, axes, and tools to remove visual clutter. Then the widget—as in the taylor_server example—can be bound to a function to update the MPL plot, re-render to bitmap, load into image_rgba, etc.

This should work in theory, although I would again strongly hazard against using this method.

We the Bokeh team are constantly trying to strike a balance between closing off issues for smaller use-cases like this one and developing larger features to broaden Bokeh’s capabilities, but it’s clear that this can be bumped in priority.

Regards,

Karan

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/CAOvoNRQawtOc8f35WB_xNj3R0HmqOHXj-kxQUDHuDSF6Z-iMAw%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 12:48 PM, Josh Wasserstein [email protected] wrote:

Thanks Karan. You are correct. That’s exactly what I am looking for. I guess that there is no way to do this now. Would it be possible to have the bar plot come from matplotlib? (perhaps rendered as a bitmap). Is this something that Bokeh supports?

More generally, and I understand that this departs from the original question, can I use matplotlib to render a figure as a bitmap and then use some Bokeh widget to display it within an HBox VBox, or equivalent?

Josh

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/CAD4ivxUDCTyEJHDMZohAZa4sP_7Vu-f2CJON%2BVYgsDU5AdUr4g%40mail.gmail.com.

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

On Wed, Aug 27, 2014 at 12:18 PM, Karan Dodia [email protected] wrote:

Hello Josh,

It seems like you are trying to set up a categorical x-axis; am I correct in assuming that?

Unfortunately Bokeh does not support changing categorical axes at the moment; there is an open issue to track this behavior, and a related gist I’ve written up that demonstrates a code snippet that should work (but doesn’t currently).

I’ll make a note to ping you if I can resolve this in the near future.

Thanks!

Karan

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].

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

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAOvoNRQXa3b1W5NvBbkQgWwAaRauH71%2Bf2v87OK0Mg_mkLJNKw%40mail.gmail.com.

On Wed, Aug 27, 2014 at 10:56 AM, Josh Wasserstein [email protected] wrote:

Hi,

I am trying to build a document an example similar in spirit to taylor_server.py but with a bar chart instead (rather than a regular line plot). Assuming that my data is, for example:

labels = [‘foo’, bar’]

values = [-1, -2]

What changes specifically do I need to make?

The original taylor_server.py has roughly the following code to create the plot (ignoring the other widgets for now). Any pointers (even minor modifications to the code below) would be greatly appreciated!

from bokeh.objects import Plot, DataRange1d, LinearAxis, ColumnDataSource, Glyph, Grid, Legend

from bokeh.widgetobjects import VBox,

from bokeh.glyphs import Patch, Line, Text

from bokeh.document import Document

from bokeh.session import Session

source = ColumnDataSource(data=dict(

x = [1, 2, 3],

y = [0, 10, 100]

))

xdr = DataRange1d(sources=[source.columns(“x”)])

ydr = DataRange1d(sources=[source.columns(“y”)])

plot = Plot(x_range=xdr, y_range=ydr, plot_width=800, plot_height=400)

line_f = Line(x=“x”, y=“y”, line_color=“blue”, line_width=2)

line_f_glyph = Glyph(data_source=source, xdata_range=xdr, ydata_range=ydr, glyph=line_f)

plot.renderers.append(line_f_glyph)

xaxis = LinearAxis(plot=plot)

plot.below.append(xaxis)

yaxis = LinearAxis(plot=plot)

plot.left.append(yaxis)

xgrid = Grid(plot=plot, dimension=0, ticker=xaxis.ticker)

ygrid = Grid(plot=plot, dimension=1, ticker=yaxis.ticker)

layout = VBox(children=[plot])

document.add(layout)

Josh

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/CAD4ivxX6gXsWaVTvQ_dcUjdnqWhfyYDF23kR%3DoTGsWvBtuqmSw%40mail.gmail.com.

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