# Overlaying second set of points based on selection stream from first set

**URL:** <https://discourse.holoviz.org/t/overlaying-second-set-of-points-based-on-selection-stream-from-first-set/3362>\
**Category:** HoloViews\
**Tags:** panel\
**Created:** [February 11, 2022, 6:11pm UTC](https://discourse.holoviz.org/t/overlaying-second-set-of-points-based-on-selection-stream-from-first-set/3362 "2022-02-11T18:11:05Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![sbi\_vm](https://discourse.holoviz.org/letter_avatar_proxy/v4/letter/s/5e9695/32.png) [@sbi\_vm](https://discourse.holoviz.org/u/sbi_vm)\
**Post date:** [February 11, 2022, 8:40pm UTC](https://discourse.holoviz.org/t/overlaying-second-set-of-points-based-on-selection-stream-from-first-set/3362/2 "2022-02-11T20:40:07Z")

</div>

Success! I stumbled across this related one: [Dynamically fetch other column value from selection1D stream](https://discourse.holoviz.org/t/dynamically-fetch-other-column-value-from-selection1d-stream/720)

…and I think this revised section works:

```auto
point_size_slider = pn.widgets.IntSlider(name="Point Size",start=3,end=12,value=7)

@pn.depends(size=point_size_slider.param.value)
def base_points(size):
    return gv.Points(gv_table,kdims=['Longitude','Latitude'],vdims=['City','Country']).opts(size=size,tools=['lasso_select'],nonselection_alpha=0.2)

test = hv.DynamicMap(base_points)

sel = streams.Selection1D(source=test)

def get_countries(table, index):
    temp_ds = hv.Dataset(table.iloc[index]['Country'], 'Country')
    #lst = (temp_ds[()].data['Country'].values[:])
    return hv.Table(temp_ds[()].data['Country'])

def highlight_missed(table, index):
    '''
    Add another layer of points (empty black circle outlines) for the selected points; but expand visible points to all that share country label
    '''
    if len(index)>0:
        selected_countries = list(hv.Dataset(table.iloc[index]['Country'], 'Country')[()].data['Country'])
        return gv.Points(table.select(Country=selected_countries),kdims=['Longitude','Latitude'],vdims=['City','Country']).opts(size=7,nonselection_alpha=1.0,fill_color=None,line_width=1,line_color='black')
    else:
        return gv.Points(table,kdims=['Longitude','Latitude'],vdims=['City','Country']).opts(size=7,fill_color=None,line_width=1,line_color='black')

test2 = gv_table.apply(highlight_missed, streams=[sel])
id_dmap = gv_table.apply(get_countries, streams=[sel])

plot = tiles*test*test2
layout = pn.Row(pn.Column(point_size_slider,plot.opts(width=600,height=600)),id_dmap)
layout

```

(also added the hv.table to help check things while troubleshooting)

![image](https://discourse.holoviz.org/uploads/default/original/2X/b/baa789f12cff4c5a8eb3e7ba717b2be6b36418c6.png)

---

_[View the full topic](https://discourse.holoviz.org/t/overlaying-second-set-of-points-based-on-selection-stream-from-first-set/3362)._
