【问题标题】:hvplot - how to colour point data by categorical variable and aggregate with `ds.count_cat(.)`hvplot - 如何通过分类变量为点数据着色并与 `ds.count_cat(.)` 聚合
【发布时间】:2019-06-07 22:21:52
【问题描述】:

我正在尝试使用 hvplot 重新创建 datashader census 分类示例。

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.',)".

【问题讨论】:

    标签: python holoviews datashader pyviz hvplot


    【解决方案1】:

    事实证明,我没有在任何全息视图维度中定义要着色的变量“种族”。可以通过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")
    

    【讨论】:

      猜你喜欢
      • 2018-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-18
      • 1970-01-01
      • 1970-01-01
      • 2020-11-17
      相关资源
      最近更新 更多