The categories of a bars chart

The following MWE:

vals = [10, 5]
cat = [‘14 30’, ‘15 30’]
bar = Bar(vals, cat, title=“Stacked bars”,
xlabel=“category”, ylabel=“language”)
bar.notebook().show()

``

However, if I change the second line:

cat = [‘14:30’, ‘15:30’]

``

the bars are not plotted. What is the reason for this? Is it a bug or misuse?

``

And bonus question: how do I change the color of the bars?

···

On Tuesday, February 24, 2015 at 11:16:02 AM UTC+1, Dror Atariah wrote:

The following MWE:

vals = [10, 5]
cat = [‘14 30’, ‘15 30’]
bar = Bar(vals, cat, title=“Stacked bars”,
xlabel=“category”, ylabel=“language”)
bar.notebook().show()

``

However, if I change the second line:

cat = [‘14:30’, ‘15:30’]

``

the bars are not plotted. What is the reason for this? Is it a bug or misuse?

``

Hi Dror,

It is known a bug with colons in category names. There is a related open GH issue.

Regarding your question about the colors, you can just specify the palette argument, like this:

palette=[‘#83255A’, ‘#008000’]

``

Also, looking at you example I’d suggest a few things:

Seems that you want to specify 2 categories but you are only providing one iterable with scalar values. So if you want to have multiple values on each category you should be specifying a 2d iterable like:

vals = [[10, 4], [5, 2]]

``

Also, chart notebook method excpects a boolean value, so you should be calling it like:

bar.notebook(True).show()

``

but I’d invite you to prefer specifying notebook=True argument when creating the Bard chart or to use the explicit output_notebook and show methods from the plotting interface. This is more explicit and in the next versions is very likely that those methods will become the preferred way (and shared among all bokeh interface levels). See the following example:

from bokeh.plotting import output_notebook, show
vals = [[10, 4], [5, 2]]
cat = [‘14 30’, ‘15 30’]
bar = Bar(vals, cat, title=“Stacked bars”,
xlabel=“category”, ylabel=“language”, palette=[‘#83255A’, ‘#008000’])
output_notebook()
show(bar)

``

Best

Fabio

···

On Tuesday, February 24, 2015 at 11:29:30 AM UTC+1, Dror Atariah wrote:

And bonus question: how do I change the color of the bars?

On Tuesday, February 24, 2015 at 11:16:02 AM UTC+1, Dror Atariah wrote:

The following MWE:

vals = [10, 5]
cat = [‘14 30’, ‘15 30’]
bar = Bar(vals, cat, title=“Stacked bars”,
xlabel=“category”, ylabel=“language”)
bar.notebook().show()

``

However, if I change the second line:

cat = [‘14:30’, ‘15:30’]

``

the bars are not plotted. What is the reason for this? Is it a bug or misuse?

``

Fabio,

I thought I was writing a quick reply to someone on stackoverflow the other day then got my knickers in a right twist about the show method and had to edit multiple times.

Can you please confirm the accuracy of https://stackoverflow.com/questions/28655096/plot-the-whole-pandas-dataframe-with-bokeh/28662599#28662599

And if there’s anything that can be added for completeness, please do comment or let me know.

Many thanks,

Sarah Bird

···

On Tue, Feb 24, 2015 at 2:53 AM, Fabio Pliger [email protected] wrote:

Hi Dror,

It is known a bug with colons in category names. There is a related open GH issue.

Regarding your question about the colors, you can just specify the palette argument, like this:

palette=[‘#83255A’, ‘#008000’]

``

Also, looking at you example I’d suggest a few things:

Seems that you want to specify 2 categories but you are only providing one iterable with scalar values. So if you want to have multiple values on each category you should be specifying a 2d iterable like:

vals = [[10, 4], [5, 2]]

``

Also, chart notebook method excpects a boolean value, so you should be calling it like:

bar.notebook(True).show()

``

but I’d invite you to prefer specifying notebook=True argument when creating the Bard chart or to use the explicit output_notebook and show methods from the plotting interface. This is more explicit and in the next versions is very likely that those methods will become the preferred way (and shared among all bokeh interface levels). See the following example:

from bokeh.plotting import output_notebook, show
vals = [[10, 4], [5, 2]]
cat = [‘14 30’, ‘15 30’]
bar = Bar(vals, cat, title=“Stacked bars”,
xlabel=“category”, ylabel=“language”, palette=[‘#83255A’, ‘#008000’])
output_notebook()
show(bar)

``

Best

Fabio

On Tuesday, February 24, 2015 at 11:29:30 AM UTC+1, Dror Atariah wrote:

And bonus question: how do I change the color of the bars?

On Tuesday, February 24, 2015 at 11:16:02 AM UTC+1, Dror Atariah wrote:

The following MWE:

vals = [10, 5]
cat = [‘14 30’, ‘15 30’]
bar = Bar(vals, cat, title=“Stacked bars”,
xlabel=“category”, ylabel=“language”)
bar.notebook().show()

``

However, if I change the second line:

cat = [‘14:30’, ‘15:30’]

``

the bars are not plotted. What is the reason for this? Is it a bug or misuse?

``

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/f10c74bb-a091-4104-a359-079301f2c0da%40continuum.io.

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

Hi Sarah,

Already commented on SO… great answer. Thank you once again for your contributions!

Cheers

Fabio

···

On Tuesday, February 24, 2015 at 6:51:54 PM UTC+1, Sarah Bird wrote:

Fabio,

I thought I was writing a quick reply to someone on stackoverflow the other day then got my knickers in a right twist about the show method and had to edit multiple times.

Can you please confirm the accuracy of https://stackoverflow.com/questions/28655096/plot-the-whole-pandas-dataframe-with-bokeh/28662599#28662599

And if there’s anything that can be added for completeness, please do comment or let me know.

Many thanks,

Sarah Bird