# Plotting d3.grouped data?

**URL:** <https://talk.observablehq.com/t/plotting-d3-grouped-data/5651>\
**Category:** Help\
**Created:** [October 3, 2021, 7:50pm UTC](https://talk.observablehq.com/t/plotting-d3-grouped-data/5651 "2021-10-03T19:50:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaronkyle](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/aaronkyle/32/8106_2.png) [@aaronkyle](https://talk.observablehq.com/u/aaronkyle)\
**Post date:** [October 3, 2021, 7:50pm UTC](https://talk.observablehq.com/t/plotting-d3-grouped-data/5651/1 "2021-10-03T19:50:24Z")

</div>

Hi Community!

I am starting to learn [Plot](https://observablehq.com/@observablehq/plot) and would appreciate a bit of help and guidance.

I like to work with d3.group to organize information, and often I’d like to visualize the outcomes of these groupings. For example, in the notebook linked below, I made up some information describing plot ownership in an area. I’d like to create a simple [bar chart](https://observablehq.com/@observablehq/plot-bar) showing the number of different ownership types per village, and I really have not idea what steps I would need to take to get there:

> **[Learning How to Plot with Grouped / Mapped Data](https://observablehq.com/d/6ccc96cfd146f03e)**
>
> First, well load in some data. I'll do this 'manually' with a made-up dataset—pasting in the table from Excel and paring it into an Array of Objects with D3: My data have some funny headers. I'll strip those out. Let's now ask some basic questions of...

Any tips?

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [October 3, 2021, 8:18pm UTC](https://talk.observablehq.com/t/plotting-d3-grouped-data/5651/2 "2021-10-03T20:18:48Z")

</div>

I’ve sent a suggestion to get you started. The “distinct” reducer on Plot.groupX counts the number of different “things” it sees in each group, thus:

```auto
Plot.barY(cleaned_data, Plot.groupX({y: "distinct"}, {x: "village", y: "ownership_type"})).plot()

```

---

<div class="post-metadata">

**Author:** ![aaronkyle](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/aaronkyle/32/8106_2.png) [@aaronkyle](https://talk.observablehq.com/u/aaronkyle)\
**Post date:** [October 3, 2021, 8:51pm UTC](https://talk.observablehq.com/t/plotting-d3-grouped-data/5651/3 "2021-10-03T20:51:12Z")

</div>

Thanks @fil! I didn’t quite grasp that the ‘groupX’ and ‘groupY’ were actually _doing_ the groupings! 🙂 So simple!
