🏠 back to Observable

Plotting d3.grouped data?

Hi Community!

I am starting to learn 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 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:

Any tips?

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:

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

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

1 Like