我正在尝试使用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.',)".
答案 0 :(得分:1)
事实证明,我没有在任何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")