# Plot: group and sort question

**URL:** <https://talk.observablehq.com/t/plot-group-and-sort-question/7757>\
**Category:** Help\
**Created:** [March 17, 2023, 7:21pm UTC](https://talk.observablehq.com/t/plot-group-and-sort-question/7757 "2023-03-17T19:21:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mferro64](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mferro64/32/6421_2.png) [@mferro64](https://talk.observablehq.com/u/mferro64)\
**Post date:** [March 17, 2023, 7:21pm UTC](https://talk.observablehq.com/t/plot-group-and-sort-question/7757/1 "2023-03-17T19:21:53Z")

</div>

I have a sorting problem I need some help on. The notebook example has 2 charts. Chart 1 has the grouping by vote sorted and labeled in the legend correctly.

In chart 2 I would like to have the x axis display the _individual_ congressmen OR senators vote but be grouped by vote & display the appropriate color in the legend like in chart 1.

I hope this makes sense- any help is appreciated in advance

> **[bill\_test](https://observablehq.com/d/020f5ee723f73207)**

---

<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:** [March 17, 2023, 9:31pm UTC](https://talk.observablehq.com/t/plot-group-and-sort-question/7757/2 "2023-03-17T21:31:04Z")

</div>

If you need individual points, you can remove the group operation; use x: 1 instead to create a bar of width 1 for each person:

`Plot.barX(bill, {x: 1, y: "Party", fill: "Vote", inset: 0.5, sort: {y: "x", reverse: true}, title: (d) => d.Name + "\n" + d.Party + "\n" + d.Chamber + "\n" + d.Vote}),`

---

<div class="post-metadata">

**Author:** ![mferro64](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mferro64/32/6421_2.png) [@mferro64](https://talk.observablehq.com/u/mferro64)\
**Post date:** [March 17, 2023, 9:42pm UTC](https://talk.observablehq.com/t/plot-group-and-sort-question/7757/3 "2023-03-17T21:42:21Z")

</div>

> [@Fil](#):
>
> Plot.barX(bill, {x: 1, y: “Party”, fill: “Vote”, inset: 0.5, sort: {y: “x”, reverse: true}, title: (d) =\> d.Name + “\n” + d.Party + “\n” + d.Chamber + “\n” + d.Vote}),

Thank you - that worked!
