# Linked brushing with bar chart

**URL:** <https://discourse.holoviz.org/t/linked-brushing-with-bar-chart/6049>\
**Category:** HoloViews\
**Tags:** link-selection\
**Created:** [September 18, 2023, 7:43pm UTC](https://discourse.holoviz.org/t/linked-brushing-with-bar-chart/6049 "2023-09-18T19:43:49Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![anitagraser](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/anitagraser/32/158_2.png) [@anitagraser](https://discourse.holoviz.org/u/anitagraser)\
**Post date:** [September 18, 2023, 8:14pm UTC](https://discourse.holoviz.org/t/linked-brushing-with-bar-chart/6049/2 "2023-09-18T20:14:06Z")

</div>

Ok, found it thanks to [Linked tap selections in stacked bar plots - #2 by Marc](https://discourse.holoviz.org/t/linked-tap-selections-in-stacked-bar-plots/956/2) and [RangeXY — HoloViews v1.17.1](https://holoviews.org/reference/streams/bokeh/RangeXY.html)

```auto
def selected_bar_plot(x_range, y_range):
    if x_range:
        tmp = df[(df.x>x_range[0])&(df.x<x_range[1])]
    else:
        tmp = df
    return tmp.groupby("ShipType").count().hvplot.bar(x="ShipType", y='MMSI', width=400, rot=90)

map_plot = df.hvplot.scatter(x='x', y='y', c="ShipType", width=700, height=300)
rangexy = hv.streams.RangeXY(source=map_plot)
    
map_plot << hv.DynamicMap(selected_bar_plot, streams=[rangexy])

```

![linked-bar](https://discourse.holoviz.org/uploads/default/original/2X/4/4deb097ed420e69bc8522ae9e69c7d0e87a7fb40.gif)

---

_[View the full topic](https://discourse.holoviz.org/t/linked-brushing-with-bar-chart/6049)._
