How to specify colormap for categories when using `ds.count_cat()`

I’m trying to use a custom mapping from categories to colors when datashading categories with ds.count_cat(). How can I do this, if it’s possible?

I tried using the cmap keyword argument but it seems to be ignored.

Sorry if this has been answered elsewhere, but I couldn’t find the answer after several minutes of checking the docs, GitHub, and StackOverflow.

We should probably issue a warning suggesting the right solution. When using count_cat you should use a color_key, either mapping each category to a color explicitly as a dictionary or providing a list of colors at least as long as the number of categories.

Thanks! I could submit a PR for that—or perhaps even better, add some documentation—if you could point me in direction of the relevant files?

To be clear you’re using datashader directly or via HoloViews?

I’m using it via Holoviews (hv.operations.datashader).

Along similar lines, am i able to specify colors to polygons from a GeoDataFrame using datashader (rendering 28,000 polygons)?
e.g. agg=df.count_cat(‘category_name’)

I’m currently using agg=ds.mean(‘category_name’) and pointing to numeric classes as a workaround, but this changes dynamically. Perhaps I’m doing this completely backwards? But i love that I can render and zoom in on these polygons! Such beautiful tools you’ve developed!