我试图用datashader census重新创建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.',)".
最佳答案
事实证明,我没有在任何holoviews尺寸中定义要在“ race”上着色的变量。可以通过vdims
将其添加到c="race"
(c
表示要在其上进行着色的列):
完整代码应为(包括自定义颜色图):
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")
关于python - hvplot-如何通过分类变量为点数据着色并使用ds.count_cat(.)进行聚合,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56501827/