reworking an example, filters don't seem to be working

I am using some of the new features, and trying to combine Handling Categorical Data — Bokeh 0.12.7 documentation with boolean filters Providing Data for Plots and Tables — Bokeh 0.12.7 documentation

I am changing the visual dodge to have the data all in a column (like one would have to do with altair)

So I am creating a view for each of the three vbar data sets

but it is not working - so my question is - is there a way to view the data in a view to aid in troubleshooting, any ideas on how to further troubleshoot?

Here is the example:

the 2015 data is showing up but not the 2016 and 2017 vbars:

from bokeh.core.properties import value

from bokeh.io import show, output_notebook

from bokeh.models import ColumnDataSource

from bokeh.plotting import figure

from bokeh.transform import dodge

from bokeh.models import ColumnDataSource, CDSView, BooleanFilter

output_notebook()

fruits = [‘Apples’, ‘Pears’, ‘Nectarines’, ‘Plums’, ‘Grapes’, ‘Strawberries’]

years = [‘2015’, ‘2016’, ‘2017’]

data = {‘fruits’ :[‘Apples’, ‘Pears’, ‘Nectarines’, ‘Plums’, ‘Grapes’, ‘Strawberries’,

‘Apples’, ‘Pears’, ‘Nectarines’, ‘Plums’, ‘Grapes’, ‘Strawberries’,

‘Apples’, ‘Pears’, ‘Nectarines’, ‘Plums’, ‘Grapes’, ‘Strawberries’],

‘date’: [‘2015’,‘2015’,‘2015’,‘2015’,‘2015’,‘2015’,

‘2016’,‘2016’,‘2016’,‘2016’,‘2016’,‘2016’,

‘2017’, ‘2017’,‘2017’,‘2017’,‘2017’,‘2017’],

‘nums’: [2, 1, 4, 3, 2, 4,

5, 3, 3, 2, 4, 6,

3, 2, 4, 4, 5, 3]

}

source = ColumnDataSource(data=data)

view2015 = CDSView(source=source, filters=[BooleanFilter([True if date == ‘2015’ else False for date in source.data[‘date’]])])

view2016 = CDSView(source=source, filters=[BooleanFilter([True if date == ‘2016’ else False for date in source.data[‘date’]])])

view2017 = CDSView(source=source, filters=[BooleanFilter([True if date == ‘2017’ else False for date in source.data[‘date’]])])

p = figure(x_range=fruits, y_range=(0, 10), plot_height=250, title=“Fruit Counts by Year”,

toolbar_location=None, tools="")

p.vbar(x=dodge(‘fruits’, -0.25, range=p.x_range), top=‘nums’, width=0.2, source=source, view=view2015,

color=“green”, legend=value(“2015”))

p.vbar(x=dodge(‘fruits’, 0, range=p.x_range), top=‘nums’, width=0.2, source=source, view=view2016,

color=“red”, legend=value(“2016”))

p.vbar(x=dodge(‘fruits’, 0.25, range=p.x_range), top=‘nums’, width=0.2, source=source, view=view2017,

color=“blue”, legend=value(“2017”))

p.x_range.range_padding = 0.1

p.xgrid.grid_line_color = None

p.legend.location = “top_left”

p.legend.orientation = “horizontal”

show(p)

Hi,

After some experimentation I think this is definitely a bug. If you move the 2016 values to the front, than that's the one that gets displayed. I have a quick hunch that things are only displaying if the first view filter value happens to be True. Will need some investigation to figure out for certain, though. Can you make a GH issue? Thanks for your patience with a new and complex feature.

Bryan

···

On Sep 7, 2017, at 09:17, [email protected] wrote:

I am using some of the new features, and trying to combine Handling Categorical Data — Bokeh 0.12.7 documentation with boolean filters Providing Data for Plots and Tables — Bokeh 0.12.7 documentation
I am changing the visual dodge to have the data all in a column (like one would have to do with altair)
So I am creating a view for each of the three vbar data sets
but it is not working - so my question is - is there a way to view the data in a view to aid in troubleshooting, any ideas on how to further troubleshoot?

Here is the example:
the 2015 data is showing up but not the 2016 and 2017 vbars:

from bokeh.core.properties import value
from bokeh.io import show, output_notebook
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure
from bokeh.transform import dodge
from bokeh.models import ColumnDataSource, CDSView, BooleanFilter

output_notebook()

fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']
years = ['2015', '2016', '2017']

data = {'fruits' :['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries',
                  'Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries',
                  'Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries'],
        'date': ['2015','2015','2015','2015','2015','2015',
                '2016','2016','2016','2016','2016','2016',
                '2017', '2017','2017','2017','2017','2017'],
        'nums': [2, 1, 4, 3, 2, 4,
                 5, 3, 3, 2, 4, 6,
                 3, 2, 4, 4, 5, 3]
       }

source = ColumnDataSource(data=data)

view2015 = CDSView(source=source, filters=[BooleanFilter([True if date == '2015' else False for date in source.data['date']])])
view2016 = CDSView(source=source, filters=[BooleanFilter([True if date == '2016' else False for date in source.data['date']])])
view2017 = CDSView(source=source, filters=[BooleanFilter([True if date == '2017' else False for date in source.data['date']])])

p = figure(x_range=fruits, y_range=(0, 10), plot_height=250, title="Fruit Counts by Year",
           toolbar_location=None, tools="")

p.vbar(x=dodge('fruits', -0.25, range=p.x_range), top='nums', width=0.2, source=source, view=view2015,
       color="green", legend=value("2015"))

p.vbar(x=dodge('fruits', 0, range=p.x_range), top='nums', width=0.2, source=source, view=view2016,
       color="red", legend=value("2016"))

p.vbar(x=dodge('fruits', 0.25, range=p.x_range), top='nums', width=0.2, source=source, view=view2017,
       color="blue", legend=value("2017"))

p.x_range.range_padding = 0.1
p.xgrid.grid_line_color = None
p.legend.location = "top_left"
p.legend.orientation = "horizontal"

show(p)

--
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/52d01959-0ab0-4bf2-b1f0-aeb42834e3a1%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Another bit of information: If I change one of the vbars to circle, then that does show up in addition to the bars. So this seems like a bug with filters and repeated use of the same glyph, perhaps.

Thanks,

Bryan

···

On Sep 7, 2017, at 21:21, Bryan Van de ven <[email protected]> wrote:

Hi,

After some experimentation I think this is definitely a bug. If you move the 2016 values to the front, than that's the one that gets displayed. I have a quick hunch that things are only displaying if the first view filter value happens to be True. Will need some investigation to figure out for certain, though. Can you make a GH issue? Thanks for your patience with a new and complex feature.

Bryan

On Sep 7, 2017, at 09:17, [email protected] wrote:

I am using some of the new features, and trying to combine Handling Categorical Data — Bokeh 0.12.7 documentation with boolean filters Providing Data for Plots and Tables — Bokeh 0.12.7 documentation
I am changing the visual dodge to have the data all in a column (like one would have to do with altair)
So I am creating a view for each of the three vbar data sets
but it is not working - so my question is - is there a way to view the data in a view to aid in troubleshooting, any ideas on how to further troubleshoot?

Here is the example:
the 2015 data is showing up but not the 2016 and 2017 vbars:

from bokeh.core.properties import value
from bokeh.io import show, output_notebook
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure
from bokeh.transform import dodge
from bokeh.models import ColumnDataSource, CDSView, BooleanFilter

output_notebook()

fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']
years = ['2015', '2016', '2017']

data = {'fruits' :['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries',
                 'Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries',
                 'Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries'],
       'date': ['2015','2015','2015','2015','2015','2015',
               '2016','2016','2016','2016','2016','2016',
               '2017', '2017','2017','2017','2017','2017'],
       'nums': [2, 1, 4, 3, 2, 4,
                5, 3, 3, 2, 4, 6,
                3, 2, 4, 4, 5, 3]
      }

source = ColumnDataSource(data=data)

view2015 = CDSView(source=source, filters=[BooleanFilter([True if date == '2015' else False for date in source.data['date']])])
view2016 = CDSView(source=source, filters=[BooleanFilter([True if date == '2016' else False for date in source.data['date']])])
view2017 = CDSView(source=source, filters=[BooleanFilter([True if date == '2017' else False for date in source.data['date']])])

p = figure(x_range=fruits, y_range=(0, 10), plot_height=250, title="Fruit Counts by Year",
          toolbar_location=None, tools="")

p.vbar(x=dodge('fruits', -0.25, range=p.x_range), top='nums', width=0.2, source=source, view=view2015,
      color="green", legend=value("2015"))

p.vbar(x=dodge('fruits', 0, range=p.x_range), top='nums', width=0.2, source=source, view=view2016,
      color="red", legend=value("2016"))

p.vbar(x=dodge('fruits', 0.25, range=p.x_range), top='nums', width=0.2, source=source, view=view2017,
      color="blue", legend=value("2017"))

p.x_range.range_padding = 0.1
p.xgrid.grid_line_color = None
p.legend.location = "top_left"
p.legend.orientation = "horizontal"

show(p)

--
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/52d01959-0ab0-4bf2-b1f0-aeb42834e3a1%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Done:

···

On Thursday, September 7, 2017 at 10:23:16 PM UTC-4, Bryan Van de ven wrote:

Another bit of information: If I change one of the vbars to circle, then that does show up in addition to the bars. So this seems like a bug with filters and repeated use of the same glyph, perhaps.

Thanks,

Bryan

On Sep 7, 2017, at 21:21, Bryan Van de ven [email protected] wrote:

Hi,

After some experimentation I think this is definitely a bug. If you move the 2016 values to the front, than that’s the one that gets displayed. I have a quick hunch that things are only displaying if the first view filter value happens to be True. Will need some investigation to figure out for certain, though. Can you make a GH issue? Thanks for your patience with a new and complex feature.

Bryan

On Sep 7, 2017, at 09:17, [email protected] wrote:

I am using some of the new features, and trying to combine http://bokeh.pydata.org/en/0.12.7/docs/user_guide/categorical.html#visual-dodge with boolean filters http://bokeh.pydata.org/en/0.12.7/docs/user_guide/data.html#booleanfilter

I am changing the visual dodge to have the data all in a column (like one would have to do with altair)

So I am creating a view for each of the three vbar data sets

but it is not working - so my question is - is there a way to view the data in a view to aid in troubleshooting, any ideas on how to further troubleshoot?

Here is the example:

the 2015 data is showing up but not the 2016 and 2017 vbars:

from bokeh.core.properties import value

from bokeh.io import show, output_notebook

from bokeh.models import ColumnDataSource

from bokeh.plotting import figure

from bokeh.transform import dodge

from bokeh.models import ColumnDataSource, CDSView, BooleanFilter

output_notebook()

fruits = [‘Apples’, ‘Pears’, ‘Nectarines’, ‘Plums’, ‘Grapes’, ‘Strawberries’]

years = [‘2015’, ‘2016’, ‘2017’]

data = {‘fruits’ :[‘Apples’, ‘Pears’, ‘Nectarines’, ‘Plums’, ‘Grapes’, ‘Strawberries’,

             'Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries',
             'Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries'],
   'date': ['2015','2015','2015','2015','2015','2015',
           '2016','2016','2016','2016','2016','2016',
           '2017', '2017','2017','2017','2017','2017'],
   'nums': [2, 1, 4, 3, 2, 4,
            5, 3, 3, 2, 4, 6,
            3, 2, 4, 4, 5, 3]
  }

source = ColumnDataSource(data=data)

view2015 = CDSView(source=source, filters=[BooleanFilter([True if date == ‘2015’ else False for date in source.data[‘date’]])])

view2016 = CDSView(source=source, filters=[BooleanFilter([True if date == ‘2016’ else False for date in source.data[‘date’]])])

view2017 = CDSView(source=source, filters=[BooleanFilter([True if date == ‘2017’ else False for date in source.data[‘date’]])])

p = figure(x_range=fruits, y_range=(0, 10), plot_height=250, title=“Fruit Counts by Year”,

      toolbar_location=None, tools="")

p.vbar(x=dodge(‘fruits’, -0.25, range=p.x_range), top=‘nums’, width=0.2, source=source, view=view2015,

  color="green", legend=value("2015"))

p.vbar(x=dodge(‘fruits’, 0, range=p.x_range), top=‘nums’, width=0.2, source=source, view=view2016,

  color="red", legend=value("2016"))

p.vbar(x=dodge(‘fruits’, 0.25, range=p.x_range), top=‘nums’, width=0.2, source=source, view=view2017,

  color="blue", legend=value("2017"))

p.x_range.range_padding = 0.1

p.xgrid.grid_line_color = None

p.legend.location = “top_left”

p.legend.orientation = “horizontal”

show(p)


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/52d01959-0ab0-4bf2-b1f0-aeb42834e3a1%40continuum.io.

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