CDSView with Multiple Filters

According to the docs, CDSView can take a list of filters:

view = CDSView(source=cds, filters=[IndexFilter([0]), IndexFilter([1])])

And view.filters shows the list of 2 filters being stored. However, it isn’t clear how this can be used when drawing glyphs:

p.circle(x=‘offset’, y=‘y’, source=cds, view=view)

This doesn’t throw any errors but nothing is plotted either. When the CDSView has only one filter:

view = CDSView(source=cds, filters=[IndexFilter([0]), IndexFilter([1])])

then the circle is drawn. What I’d like to do is draw circle(s) with all of the indices from the first filter and, say, square(s) with all of the indices found in the the second filter. Ultimately, I have a long list of views and I’d like to draw different shapes using different filters. I’d like to be able to do this programmatically rather than having to manually create 3 dozen views.

Hi Sean,

I think you can use two CDSViews - one for circles and the other for squares.

Regards,

Eugene

···

On Saturday, October 21, 2017 at 2:22:24 AM UTC+7, Sean Law wrote:

According to the docs, CDSView can take a list of filters:

view = CDSView(source=cds, filters=[IndexFilter([0]), IndexFilter([1])])

And view.filters shows the list of 2 filters being stored. However, it isn’t clear how this can be used when drawing glyphs:

p.circle(x=‘offset’, y=‘y’, source=cds, view=view)

This doesn’t throw any errors but nothing is plotted either. When the CDSView has only one filter:

view = CDSView(source=cds, filters=[IndexFilter([0]), IndexFilter([1])])

then the circle is drawn. What I’d like to do is draw circle(s) with all of the indices from the first filter and, say, square(s) with all of the indices found in the the second filter. Ultimately, I have a long list of views and I’d like to draw different shapes using different filters. I’d like to be able to do this programmatically rather than having to manually create 3 dozen views.

Eugene,

I understand that but I have 36 views generated based off of the original CDS and I am seeing if there is a way to avoid having to manually generate all of those views.

···

On Friday, October 20, 2017 at 3:29:29 PM UTC-4, Eugene Pakhomov wrote:

Hi Sean,

I think you can use two CDSViews - one for circles and the other for squares.

Regards,

Eugene

On Saturday, October 21, 2017 at 2:22:24 AM UTC+7, Sean Law wrote:

According to the docs, CDSView can take a list of filters:

view = CDSView(source=cds, filters=[IndexFilter([0]), IndexFilter([1])])

And view.filters shows the list of 2 filters being stored. However, it isn’t clear how this can be used when drawing glyphs:

p.circle(x=‘offset’, y=‘y’, source=cds, view=view)

This doesn’t throw any errors but nothing is plotted either. When the CDSView has only one filter:

view = CDSView(source=cds, filters=[IndexFilter([0]), IndexFilter([1])])

then the circle is drawn. What I’d like to do is draw circle(s) with all of the indices from the first filter and, say, square(s) with all of the indices found in the the second filter. Ultimately, I have a long list of views and I’d like to draw different shapes using different filters. I’d like to be able to do this programmatically rather than having to manually create 3 dozen views.

Hi Sean and Eugene,

The other thing to note is the list of filters for a single view operates through intersection so the points that are plotted are those that satisfy all of the filters in the view.

For now I think you may need to generate all of the views, but there is an open issue for a “multi-marker” glyph that would allow you to use different markers for different points with one renderer, but that hasn’t been thought through or implemented yet.

Best,
Claire

···

On Fri, Oct 20, 2017 at 12:29 PM Eugene Pakhomov [email protected] wrote:

Hi Sean,

I think you can use two CDSViews - one for circles and the other for squares.

Regards,

Eugene

On Saturday, October 21, 2017 at 2:22:24 AM UTC+7, Sean Law wrote:

According to the docs, CDSView can take a list of filters:

view = CDSView(source=cds, filters=[IndexFilter([0]), IndexFilter([1])])

And view.filters shows the list of 2 filters being stored. However, it isn’t clear how this can be used when drawing glyphs:

p.circle(x=‘offset’, y=‘y’, source=cds, view=view)

This doesn’t throw any errors but nothing is plotted either. When the CDSView has only one filter:

view = CDSView(source=cds, filters=[IndexFilter([0]), IndexFilter([1])])

then the circle is drawn. What I’d like to do is draw circle(s) with all of the indices from the first filter and, say, square(s) with all of the indices found in the the second filter. Ultimately, I have a long list of views and I’d like to draw different shapes using different filters. I’d like to be able to do this programmatically rather than having to manually create 3 dozen views.

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/ce6358ab-6cd8-42eb-a9e3-b1687f6044de%40continuum.io.

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

Not sure I follow.
You say you have 36 views generated, but then you say you don’t want to generate them.

Can you share some code?

Eugene

···

On Saturday, October 21, 2017 at 2:49:06 AM UTC+7, Sean Law wrote:

Eugene,

I understand that but I have 36 views generated based off of the original CDS and I am seeing if there is a way to avoid having to manually generate all of those views.

On Friday, October 20, 2017 at 3:29:29 PM UTC-4, Eugene Pakhomov wrote:

Hi Sean,

I think you can use two CDSViews - one for circles and the other for squares.

Regards,

Eugene

On Saturday, October 21, 2017 at 2:22:24 AM UTC+7, Sean Law wrote:

According to the docs, CDSView can take a list of filters:

view = CDSView(source=cds, filters=[IndexFilter([0]), IndexFilter([1])])

And view.filters shows the list of 2 filters being stored. However, it isn’t clear how this can be used when drawing glyphs:

p.circle(x=‘offset’, y=‘y’, source=cds, view=view)

This doesn’t throw any errors but nothing is plotted either. When the CDSView has only one filter:

view = CDSView(source=cds, filters=[IndexFilter([0]), IndexFilter([1])])

then the circle is drawn. What I’d like to do is draw circle(s) with all of the indices from the first filter and, say, square(s) with all of the indices found in the the second filter. Ultimately, I have a long list of views and I’d like to draw different shapes using different filters. I’d like to be able to do this programmatically rather than having to manually create 3 dozen views.

Thanks, Claire. That clarifies it

···

On Friday, October 20, 2017 at 3:52:03 PM UTC-4, Claire Tang wrote:

Hi Sean and Eugene,

The other thing to note is the list of filters for a single view operates through intersection so the points that are plotted are those that satisfy all of the filters in the view.

For now I think you may need to generate all of the views, but there is an open issue for a “multi-marker” glyph that would allow you to use different markers for different points with one renderer, but that hasn’t been thought through or implemented yet.

Best,
Claire
On Fri, Oct 20, 2017 at 12:29 PM Eugene Pakhomov [email protected] wrote:

Hi Sean,

I think you can use two CDSViews - one for circles and the other for squares.

Regards,

Eugene

On Saturday, October 21, 2017 at 2:22:24 AM UTC+7, Sean Law wrote:

According to the docs, CDSView can take a list of filters:

view = CDSView(source=cds, filters=[IndexFilter([0]), IndexFilter([1])])

And view.filters shows the list of 2 filters being stored. However, it isn’t clear how this can be used when drawing glyphs:

p.circle(x=‘offset’, y=‘y’, source=cds, view=view)

This doesn’t throw any errors but nothing is plotted either. When the CDSView has only one filter:

view = CDSView(source=cds, filters=[IndexFilter([0]), IndexFilter([1])])

then the circle is drawn. What I’d like to do is draw circle(s) with all of the indices from the first filter and, say, square(s) with all of the indices found in the the second filter. Ultimately, I have a long list of views and I’d like to draw different shapes using different filters. I’d like to be able to do this programmatically rather than having to manually create 3 dozen views.

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/ce6358ab-6cd8-42eb-a9e3-b1687f6044de%40continuum.io.

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

Claire,

Is there a proper way to replace one view with another like:

view_1 = CDSView(source=cds, filters=[IndexFilter([1])])

view_2 = CDSView(source=cds, filters=[IndexFilter([2,3,4])])

view_3 = CDSView(source=cds, filters=[IndexFilter([10,11,12])])

Draw circle with view #1

p.circle(source=cds, view=view_1, name=‘circle’)

.

.

.

In a callback function, say, in a button on_click

p.select(name=‘circle’)[0].view = view_2

In a callback function, say, in another different button on_click

p.select(name=‘circle’)[0].view = view_3

This seems to lead to some unexpected behavior where the circles aren’t drawn correctly when I click on the buttons to switch to view #2 and then view #3. Maybe I’m misunderstanding how views can be changed or pushing up against the intended purpose.

···

On Friday, October 20, 2017 at 3:52:03 PM UTC-4, Claire Tang wrote:

Hi Sean and Eugene,

The other thing to note is the list of filters for a single view operates through intersection so the points that are plotted are those that satisfy all of the filters in the view.

For now I think you may need to generate all of the views, but there is an open issue for a “multi-marker” glyph that would allow you to use different markers for different points with one renderer, but that hasn’t been thought through or implemented yet.

Best,
Claire
On Fri, Oct 20, 2017 at 12:29 PM Eugene Pakhomov [email protected] wrote:

Hi Sean,

I think you can use two CDSViews - one for circles and the other for squares.

Regards,

Eugene

On Saturday, October 21, 2017 at 2:22:24 AM UTC+7, Sean Law wrote:

According to the docs, CDSView can take a list of filters:

view = CDSView(source=cds, filters=[IndexFilter([0]), IndexFilter([1])])

And view.filters shows the list of 2 filters being stored. However, it isn’t clear how this can be used when drawing glyphs:

p.circle(x=‘offset’, y=‘y’, source=cds, view=view)

This doesn’t throw any errors but nothing is plotted either. When the CDSView has only one filter:

view = CDSView(source=cds, filters=[IndexFilter([0]), IndexFilter([1])])

then the circle is drawn. What I’d like to do is draw circle(s) with all of the indices from the first filter and, say, square(s) with all of the indices found in the the second filter. Ultimately, I have a long list of views and I’d like to draw different shapes using different filters. I’d like to be able to do this programmatically rather than having to manually create 3 dozen views.

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/ce6358ab-6cd8-42eb-a9e3-b1687f6044de%40continuum.io.

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