1

I am trying to recreate the 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)

Unfortunately I'm getting:

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

1 Answers1

1

It turned out I did not define the variable to colour on, "race", within any of the holoviews dimensions. It can be added to vdims via the c="race" (c denotes which column to colour on):

enter image description here

The full code should be (including a custom colour map):

 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")

enter image description here

andyandy
  • 1,384
  • 2
  • 15
  • 25