hvplot - 如何通过分类变量为点数据着色并使用 `ds.count_cat(.)` 进行聚合

hvplot - how to colour point data by categorical variable and aggregate with `ds.count_cat(.)`

我正在尝试重新创建 datashader census categorical examples with hvplot

import cartopy.crs as ccrs
import datashader as ds
import dask.dataframe as dd
import hvplot.dask


ddf = dd.read_parquet("census2010.parq").persist()

ddf.hvplot.points(x="easting", y="northing", 
                  aggregator=ds.count_cat("race"),
                  datashade=True,
                  crs=ccrs.GOOGLE_MERCATOR)

不幸的是我得到了:

WARNING:param.dynamic_operation: Callable raised "ValueError('Aggregation column race not found on :Points   [easting,northing] element. Ensure the aggregator references an existing dimension.',)".

事实证明,我没有在任何全息视图维度内定义要着色的变量,"race"。它可以通过 c="race" 添加到 vdimsc 表示要在哪一列上着色):

完整代码应该是(包括自定义颜色图):

 ddf.hvplot.points(x="easting", y="northing", 

                      c="race",
                      cmap={'w':'aqua', 'b':'lime',  'a':'red', 'h':'fuchsia', 'o':'yellow' }

                      aggregator=ds.count_cat("race"),
                      datashade=True,
                      crs=ccrs.GOOGLE_MERCATOR,
                     ).opts(bgcolor="black")