# Plot geo - map US state

**URL:** <https://talk.observablehq.com/t/plot-geo-map-us-state/7766>\
**Category:** Help\
**Created:** [March 21, 2023, 9:47pm UTC](https://talk.observablehq.com/t/plot-geo-map-us-state/7766 "2023-03-21T21:47:40Z")\
**Posts on this page:** 6\
**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 21, 2023, 9:47pm UTC](https://talk.observablehq.com/t/plot-geo-map-us-state/7766/1 "2023-03-21T21:47:40Z")

</div>

I am using Plot Geo and trying to map the total count of legislative bills to US states. I have a BarY chart below that represents the dataset. The PLOT example maps data at the county level, but I am having a hard time translating it to the just the state.

Any help will be appreciated. Thanks.

> **[TEST\_MAP](https://observablehq.com/d/c7cf01a2e8a65a87)**
>
> Map Files

---

<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 22, 2023, 8:44am UTC](https://talk.observablehq.com/t/plot-geo-map-us-state/7766/2 "2023-03-22T08:44:09Z")

</div>

You could try and use this mark:

```auto
    Plot.geo(
      bills,
      Plot.groupZ(
        {
          fill: "count",
          geometry: ([state]) =>
            states.features.find((d) => d.properties.name === state)
        },
        { geometry: "state", z: "state" }
      )
    )

```

It groups the bills by “state”, and returns the color as the count of bills, and the geometry as the state feature with a name that matches.

---

<div class="post-metadata">

**Author:** ![mbostock](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mbostock/32/9_2.png) [@mbostock](https://talk.observablehq.com/u/mbostock)\
**Post date:** [March 22, 2023, 8:57pm UTC](https://talk.observablehq.com/t/plot-geo-map-us-state/7766/3 "2023-03-22T20:57:28Z")

</div>

You could also count the number of bills for each state using the **fill** channel like so:

```js
Plot.geo(states, { fill: (d) => d3.sum(bills, (b) => b.state === d.properties.name) })

```

---

<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 22, 2023, 9:04pm UTC](https://talk.observablehq.com/t/plot-geo-map-us-state/7766/4 "2023-03-22T21:04:12Z")

</div>

> [@mbostock](#):
>
> `Plot.geo(states, { fill: (d) => d3.sum(bills, (b) => b.state === d.properties.name) })`

Thanks - that works!

---

<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 22, 2023, 9:04pm UTC](https://talk.observablehq.com/t/plot-geo-map-us-state/7766/5 "2023-03-22T21:04:55Z")

</div>

Both solutions work - appreciate the help!

---

<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 22, 2023, 10:23pm UTC](https://talk.observablehq.com/t/plot-geo-map-us-state/7766/6 "2023-03-22T22:23:26Z")

</div>

Mike’s solution is better!
