# Keyed color map for image?

**URL:** <https://discourse.holoviz.org/t/keyed-color-map-for-image/505>\
**Category:** hvPlot\
**Created:** [April 15, 2020, 7:02pm UTC](https://discourse.holoviz.org/t/keyed-color-map-for-image/505 "2020-04-15T19:02:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![itcarroll](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/itcarroll/32/1126_2.png) [@itcarroll](https://discourse.holoviz.org/u/itcarroll)\
**Post date:** [April 15, 2020, 7:02pm UTC](https://discourse.holoviz.org/t/keyed-color-map-for-image/505/1 "2020-04-15T19:02:42Z")

</div>

How do you specify color maps for categorical (e.g. string) data?

```auto
import xarray as xr
import hvplot.xarray

da = xr.DataArray([["a", "b"],["b", "b"]], dims=("x", "y"))
da.hvplot.image()

```

This yields an error `TypeError: unsupported operand type(s) for -=: 'str' and 'float'`, but I suspect one is somehow able to map the values to colors? I hoped to specify a `color_key={"a": "#ffffff", "b": "#000000"}` (which seems to be an option for datashader), but the argument is not recognized. Is there a different approach?

---

<div class="post-metadata">

**Author:** ![philippjfr](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/philippjfr/32/7_2.png) [@philippjfr](https://discourse.holoviz.org/u/philippjfr)\
**Post date:** [April 17, 2020, 10:45am UTC](https://discourse.holoviz.org/t/keyed-color-map-for-image/505/2 "2020-04-17T10:45:37Z")

</div>

HoloViews supports providing a dictionary as a `cmap`:

```auto
da.hvplot.image(cmap={"a": "#ffffff", "b": "#000000"})

```

If you want to make an issue to make `color_key` an alias for `cmap` in the categorical case that would be appreciated.

---

<div class="post-metadata">

**Author:** ![itcarroll](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/itcarroll/32/1126_2.png) [@itcarroll](https://discourse.holoviz.org/u/itcarroll)\
**Post date:** [April 17, 2020, 2:57pm UTC](https://discourse.holoviz.org/t/keyed-color-map-for-image/505/3 "2020-04-17T14:57:24Z")

</div>

Thanks! I feel I have to explain why I didn’t figure that out on my own. My actual data is integers, and the `cmap` argument did not work in that case (no error, the Image simply won’t display, see [https://github.com/holoviz/hvplot/issues/445](https://github.com/holoviz/hvplot/issues/445)). But I have no problem converting to strings!
