plot range is not updating dynamically

To start with, I have created a empty figure and tried to update the figure dynamically when x_range is set. I was able to do it using bokeh 0.12.4 version but after upgrading to 0.12.5, it throws me an error

I was trying to set x range by : plot.x_range.factors = source.data[‘feature’]

feature dynamically changes based on selection through widgets.

Error:

error handling message Message ‘PATCH-DOC’ (revision 1): AttributeError(“unexpected attribute ‘factors’ to DataRange1d, possible attributes are bounds, callback, default_span, end, flipped, follow, follow_interval, js_event_callbacks, js_property_callbacks, max_interval, min_interval, name, names, range_padding, renderers, start, subscribed_events or tags”,)

4250947.py (6.08 KB)

Hi,

Figures default to having DataRange1d, and have for several years now. DataRange1d is a "continuous" range, does not accept a list of factors. You'd have to explicitly configure the plot's range to be a FactorRange to be able to set factors. Something like:

  In [1]: from bokeh.models import FactorRange
  
  In [2]: from bokeh.plotting import figure

  In [3]: p = figure(x_range=FactorRange())

I wouldn't be able to speculate on why anything changed between versions without a complete code example to test with.

Thanks,

Bryan

···

On Apr 25, 2017, at 09:49, Divya Mounika Gurram <[email protected]> wrote:

To start with, I have created a empty figure and tried to update the figure dynamically when x_range is set. I was able to do it using bokeh 0.12.4 version but after upgrading to 0.12.5, it throws me an error

I was trying to set x range by : plot.x_range.factors = source.data['feature']

feature dynamically changes based on selection through widgets.

Error:

error handling message Message 'PATCH-DOC' (revision 1): AttributeError("unexpected attribute 'factors' to DataRange1d, possible attributes are bounds, callback, default_span, end, flipped, follow, follow_interval, js_event_callbacks, js_property_callbacks, max_interval, min_interval, name, names, range_padding, renderers, start, subscribed_events or tags",)

--
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/09e23b5a-d3fc-42d5-b433-108dcb046b55%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
<4250947.py>

I am having a similar issue in Bokeh 0.12.6. The following throws “Range FactorRange is incompatible is Scale LinearScale”:

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)

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

show(p)

···

On Tuesday, April 25, 2017 at 7:49:50 AM UTC-7, Divya Mounika Gurram wrote:

To start with, I have created a empty figure and tried to update the figure dynamically when x_range is set. I was able to do it using bokeh 0.12.4 version but after upgrading to 0.12.5, it throws me an error

I was trying to set x range by : plot.x_range.factors = source.data[‘feature’]

feature dynamically changes based on selection through widgets.

Error:

error handling message Message ‘PATCH-DOC’ (revision 1): AttributeError(“unexpected attribute ‘factors’ to DataRange1d, possible attributes are bounds, callback, default_span, end, flipped, follow, follow_interval, js_event_callbacks, js_property_callbacks, max_interval, min_interval, name, names, range_padding, renderers, start, subscribed_events or tags”,)

You should pass the range when you call figure, not set it afterwards. If you do pass to figure, then the figure function can automagically create a categorical scale to go with the categorical range. If you set it afterwards, as you are doing below, then you change the default data range to a categorical range, but leave the default linear scale which is incompatible. Alternatively you can set p.y_scale explicitly afterward too.

Bryan

···

On Aug 23, 2017, at 11:51, parlane via Bokeh Discussion - Public <[email protected]> wrote:

I am having a similar issue in Bokeh 0.12.6. The following throws "Range FactorRange is incompatible is Scale LinearScale":

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)

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

show(p)

On Tuesday, April 25, 2017 at 7:49:50 AM UTC-7, Divya Mounika Gurram wrote:
To start with, I have created a empty figure and tried to update the figure dynamically when x_range is set. I was able to do it using bokeh 0.12.4 version but after upgrading to 0.12.5, it throws me an error

I was trying to set x range by : plot.x_range.factors = source.data['feature']

feature dynamically changes based on selection through widgets.

Error:

error handling message Message 'PATCH-DOC' (revision 1): AttributeError("unexpected attribute 'factors' to DataRange1d, possible attributes are bounds, callback, default_span, end, flipped, follow, follow_interval, js_event_callbacks, js_property_callbacks, max_interval, min_interval, name, names, range_padding, renderers, start, subscribed_events or tags",)

--
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/52b598e6-b947-4593-8077-86c155ab3612%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Hi Bryan,

Thanks for your fast reply!

For my use, I need to be able to set this after I call figure. How do I change the default linear scale?

Thanks,

Fraser

···

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

You should pass the range when you call figure, not set it afterwards. If you do pass to figure, then the figure function can automagically create a categorical scale to go with the categorical range. If you set it afterwards, as you are doing below, then you change the default data range to a categorical range, but leave the default linear scale which is incompatible. Alternatively you can set p.y_scale explicitly afterward too.

Bryan

On Aug 23, 2017, at 11:51, parlane via Bokeh Discussion - Public [email protected] wrote:

I am having a similar issue in Bokeh 0.12.6. The following throws “Range FactorRange is incompatible is Scale LinearScale”:

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)

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

show(p)

On Tuesday, April 25, 2017 at 7:49:50 AM UTC-7, Divya Mounika Gurram wrote:

To start with, I have created a empty figure and tried to update the figure dynamically when x_range is set. I was able to do it using bokeh 0.12.4 version but after upgrading to 0.12.5, it throws me an error

I was trying to set x range by : plot.x_range.factors = source.data[‘feature’]

feature dynamically changes based on selection through widgets.

Error:

error handling message Message ‘PATCH-DOC’ (revision 1): AttributeError(“unexpected attribute ‘factors’ to DataRange1d, possible attributes are bounds, callback, default_span, end, flipped, follow, follow_interval, js_event_callbacks, js_property_callbacks, max_interval, min_interval, name, names, range_padding, renderers, start, subscribed_events or tags”,)


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/52b598e6-b947-4593-8077-86c155ab3612%40continuum.io.

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

See e.g.

  https://github.com/bokeh/bokeh/blob/master/examples/models/file/colors.py#L163-L165

Bryan

···

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

Hi Bryan,

Thanks for your fast reply!

For my use, I need to be able to set this after I call figure. How do I change the default linear scale?

Thanks,

Fraser

On Wednesday, August 23, 2017 at 10:09:33 AM UTC-7, Bryan Van de ven wrote:
You should pass the range when you call figure, not set it afterwards. If you do pass to figure, then the figure function can automagically create a categorical scale to go with the categorical range. If you set it afterwards, as you are doing below, then you change the default data range to a categorical range, but leave the default linear scale which is incompatible. Alternatively you can set p.y_scale explicitly afterward too.

Bryan

> On Aug 23, 2017, at 11:51, parlane via Bokeh Discussion - Public <[email protected]> wrote:
>
> I am having a similar issue in Bokeh 0.12.6. The following throws "Range FactorRange is incompatible is Scale LinearScale":
>
> 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)
>
> p.circle(x, factors, size=15, fill_color="orange", line_color="green", line_width=3)
>
> show(p)
>
> On Tuesday, April 25, 2017 at 7:49:50 AM UTC-7, Divya Mounika Gurram wrote:
> To start with, I have created a empty figure and tried to update the figure dynamically when x_range is set. I was able to do it using bokeh 0.12.4 version but after upgrading to 0.12.5, it throws me an error
>
> I was trying to set x range by : plot.x_range.factors = source.data['feature']
>
> feature dynamically changes based on selection through widgets.
>
> Error:
>
> error handling message Message 'PATCH-DOC' (revision 1): AttributeError("unexpected attribute 'factors' to DataRange1d, possible attributes are bounds, callback, default_span, end, flipped, follow, follow_interval, js_event_callbacks, js_property_callbacks, max_interval, min_interval, name, names, range_padding, renderers, start, subscribed_events or tags",)
>
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.
> To post to this group, send email to bo...@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/52b598e6-b947-4593-8077-86c155ab3612%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/95088db8-1dc8-4840-9852-6b0218372d1f%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.