# Plot Geo: fill by color channel domain

**URL:** <https://talk.observablehq.com/t/plot-geo-fill-by-color-channel-domain/8560>\
**Category:** Help\
**Created:** [November 29, 2023, 10:02pm UTC](https://talk.observablehq.com/t/plot-geo-fill-by-color-channel-domain/8560 "2023-11-29T22:02:20Z")\
**Posts on this page:** 2\
**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:** [November 29, 2023, 10:02pm UTC](https://talk.observablehq.com/t/plot-geo-fill-by-color-channel-domain/8560/1 "2023-11-29T22:02:20Z")

</div>

I am using Plot Geo and am trying to sync the state party color domain with the total count of legislative bills per US state. I have a BarY chart above that represents the dataset with the color channel domain/range defined. When I add the same domain/range (commented out) to the Plot Geo there is no fill…

The end result should be for example - if the topic guns is selected - TN should be red and the darkest value compared to AK. Likewise, NY should be the darkest blue value compared to OR

> **[OpenStates export test](https://observablehq.com/d/5bae7265f1d1665c)**
>
> Links https://wisevoter.com/state-rankings/red-and-blue-states/ https://observablehq.com/@info474/geo-map Map Files

Any help will be appreciated. Thanks.

---

<div class="post-metadata">

**Author:** ![EE2dev](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/ee2dev/32/695_2.png) [@EE2dev](https://talk.observablehq.com/u/EE2dev)\
**Post date:** [December 5, 2023, 9:08pm UTC](https://talk.observablehq.com/t/plot-geo-fill-by-color-channel-domain/8560/2 "2023-12-05T21:08:23Z")

</div>

When you group with `Plot.groupZ()` by `z: "state"`, you have to set the correct reducer (–\> how to aggregate within each group)

- in your code, the reducer was `fill:"count"` which is what you want for a quantitative scale. But now you changed the domain to expect state names instead (not integers). That’s why the color scale could not compute a color.

- So you have to change the reducer to `fill:"first"` and also add to the input the referenced column `fill:"state"`. Now Plot knows to apply the aggregation `"first"` to the column` "state"` (pick the first element of the array of elements of this group)

```auto

    Plot.geo(
      flat_class,
      Plot.groupZ(
        {
          fill: "first",
          geometry: ([state]) =>
            states.features.find((d) => d.properties.name === state)
        },
        {
          geometry: "state",
          z: "state",
          fill: "state",
          title: (d) => d.identifier
        }
      )
    ),

```

See [OpenStates export test / ee2dev | Observable](https://observablehq.com/d/b9427f19f4aeb54c).

P.s you don’t need to hard code the domain and range to replicate a scale from another plot. Instead, you can assign the previous Plot to a named cell and then reference its scale by …`plot.scale(„color“)` to access its domain and range.
