Updating y_range to categorical

I’m attempting to define the axis range as categorical once the figure is declared, and I’m running into errors. Here’s my demo code (Bokeh 0.12.6):

from bokeh.plotting import figure, output_file, show
from bokeh.models import FactorRange
factors = [“a”, “b”, “c”, “d”, “e”, “f”, “g”, “h”]
x = [50, 40, 65, 10, 25, 37, 80, 60]
output_file(“categorical.html”)
p = figure()
p.y_range = FactorRange(factors=factors)
circle = p.circle(x, factors, size=15, fill_color=“orange”, line_color=“green”, line_width=3)
show§

``

This throws the error “Range FactorRange is incompatible is Scale LinearScale”. If I initially declare the figure as follows, it works:

p = figure(y_range=factors)

``

What am I doing wrong? A more general question might be, is there a general way to update p = figure(foo=bar) after figure() is called?

Thanks for your help! I’ve been stuck on this for days.

In addition, I have also tried:

p.y_range.factors = factors

``

However, factors is not an attribute of y_range.

···

On Wednesday, August 23, 2017 at 10:07:30 AM UTC-7, Fraser wrote:

I’m attempting to define the axis range as categorical once the figure is declared, and I’m running into errors. Here’s my demo code (Bokeh 0.12.6):

from bokeh.plotting import figure, output_file, show
from bokeh.models import FactorRange
factors = [“a”, “b”, “c”, “d”, “e”, “f”, “g”, “h”]
x = [50, 40, 65, 10, 25, 37, 80, 60]
output_file(“categorical.html”)
p = figure()
p.y_range = FactorRange(factors=factors)
circle = p.circle(x, factors, size=15, fill_color=“orange”, line_color=“green”, line_width=3)
show§

``

This throws the error “Range FactorRange is incompatible is Scale LinearScale”. If I initially declare the figure as follows, it works:

p = figure(y_range=factors)

``

What am I doing wrong? A more general question might be, is there a general way to update p = figure(foo=bar) after figure() is called?

Thanks for your help! I’ve been stuck on this for days.

Hi,

You want to do this when you *create* the figure (that is the easiest way by far)

  p = figure(y_range=factors)

The lots of coordination of different low level objects will happen auto-magically. Otherwise, you will have to take care to set up lots of low level building block pieces by hand.

Bryan

···

On Aug 23, 2017, at 12:09, 'Fraser' via Bokeh Discussion - Public <[email protected]> wrote:

In addition, I have also tried:

p.y_range.factors = factors

However, factors is not an attribute of y_range.

On Wednesday, August 23, 2017 at 10:07:30 AM UTC-7, Fraser wrote:
I'm attempting to define the axis range as categorical once the figure is declared, and I'm running into errors. Here's my demo code (Bokeh 0.12.6):

from bokeh.plotting import figure, output_file, show
from bokeh.models import FactorRange
factors = ["a", "b", "c", "d", "e", "f", "g", "h"]
x = [50, 40, 65, 10, 25, 37, 80, 60]
output_file("categorical.html")
p = figure()
p.y_range = FactorRange(factors=factors)
circle = p.circle(x, factors, size=15, fill_color="orange", line_color="green", line_width=3)
show(p)

This throws the error "Range FactorRange is incompatible is Scale LinearScale". If I initially declare the figure as follows, it works:
p = figure(y_range=factors)

What am I doing wrong? A more general question might be, is there a general way to update p = figure(foo=bar) after figure() is called?

Thanks for your help! I've been stuck on this for days.

--
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/3e381bb5-cc13-4d9f-a27b-242368e57cb1%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

And to add:

There are lots of different kinds of ranges. Only one of them (FactorRange) has .factors as an attribute, but FactorRange is not the default range because most plots are not categorical.

Bryan

···

On Aug 23, 2017, at 12:09, 'Fraser' via Bokeh Discussion - Public <[email protected]> wrote:

In addition, I have also tried:

p.y_range.factors = factors

However, factors is not an attribute of y_range.

On Wednesday, August 23, 2017 at 10:07:30 AM UTC-7, Fraser wrote:
I'm attempting to define the axis range as categorical once the figure is declared, and I'm running into errors. Here's my demo code (Bokeh 0.12.6):

from bokeh.plotting import figure, output_file, show
from bokeh.models import FactorRange
factors = ["a", "b", "c", "d", "e", "f", "g", "h"]
x = [50, 40, 65, 10, 25, 37, 80, 60]
output_file("categorical.html")
p = figure()
p.y_range = FactorRange(factors=factors)
circle = p.circle(x, factors, size=15, fill_color="orange", line_color="green", line_width=3)
show(p)

This throws the error "Range FactorRange is incompatible is Scale LinearScale". If I initially declare the figure as follows, it works:
p = figure(y_range=factors)

What am I doing wrong? A more general question might be, is there a general way to update p = figure(foo=bar) after figure() is called?

Thanks for your help! I've been stuck on this for days.

--
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/3e381bb5-cc13-4d9f-a27b-242368e57cb1%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

OK - I will take your advice and rework things so it happens automagically. Thanks for your help, Bryan!

···

On Wednesday, August 23, 2017 at 10:14:23 AM UTC-7, Bryan Van de ven wrote:

And to add:

There are lots of different kinds of ranges. Only one of them (FactorRange) has .factors as an attribute, but FactorRange is not the default range because most plots are not categorical.

Bryan

On Aug 23, 2017, at 12:09, ‘Fraser’ via Bokeh Discussion - Public [email protected] wrote:

In addition, I have also tried:

p.y_range.factors = factors

However, factors is not an attribute of y_range.

On Wednesday, August 23, 2017 at 10:07:30 AM UTC-7, Fraser wrote:

I’m attempting to define the axis range as categorical once the figure is declared, and I’m running into errors. Here’s my demo code (Bokeh 0.12.6):

from bokeh.plotting import figure, output_file, show

from bokeh.models import FactorRange

factors = [“a”, “b”, “c”, “d”, “e”, “f”, “g”, “h”]

x = [50, 40, 65, 10, 25, 37, 80, 60]

output_file(“categorical.html”)

p = figure()

p.y_range = FactorRange(factors=factors)

circle = p.circle(x, factors, size=15, fill_color=“orange”, line_color=“green”, line_width=3)

show§

This throws the error “Range FactorRange is incompatible is Scale LinearScale”. If I initially declare the figure as follows, it works:

p = figure(y_range=factors)

What am I doing wrong? A more general question might be, is there a general way to update p = figure(foo=bar) after figure() is called?

Thanks for your help! I’ve been stuck on this for days.


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/3e381bb5-cc13-4d9f-a27b-242368e57cb1%40continuum.io.

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

If you pass factors to figure initially, then y_range will be a FactorRange, you can always set its .factors to something different later.

Bryan

···

On Aug 23, 2017, at 12:16, 'Fraser' via Bokeh Discussion - Public <[email protected]> wrote:

OK - I will take your advice and rework things so it happens automagically. Thanks for your help, Bryan!

On Wednesday, August 23, 2017 at 10:14:23 AM UTC-7, Bryan Van de ven wrote:
And to add:

There are lots of different kinds of ranges. Only one of them (FactorRange) has .factors as an attribute, but FactorRange is not the default range because most plots are not categorical.

Bryan

> On Aug 23, 2017, at 12:09, 'Fraser' via Bokeh Discussion - Public <[email protected]> wrote:
>
> In addition, I have also tried:
>
> p.y_range.factors = factors
>
>
> However, factors is not an attribute of y_range.
>
> On Wednesday, August 23, 2017 at 10:07:30 AM UTC-7, Fraser wrote:
> I'm attempting to define the axis range as categorical once the figure is declared, and I'm running into errors. Here's my demo code (Bokeh 0.12.6):
>
> from bokeh.plotting import figure, output_file, show
> from bokeh.models import FactorRange
> factors = ["a", "b", "c", "d", "e", "f", "g", "h"]
> x = [50, 40, 65, 10, 25, 37, 80, 60]
> output_file("categorical.html")
> p = figure()
> p.y_range = FactorRange(factors=factors)
> circle = p.circle(x, factors, size=15, fill_color="orange", line_color="green", line_width=3)
> show(p)
>
>
> This throws the error "Range FactorRange is incompatible is Scale LinearScale". If I initially declare the figure as follows, it works:
> p = figure(y_range=factors)
>
> What am I doing wrong? A more general question might be, is there a general way to update p = figure(foo=bar) after figure() is called?
>
> Thanks for your help! I've been stuck on this for days.
>
> --
> 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/3e381bb5-cc13-4d9f-a27b-242368e57cb1%40continuum.io.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/1dfbc601-84d4-45cc-be1e-be15f2d8d988%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.