Show categorical legend with hvplot's by keyword and datashader.#1238
Show categorical legend with hvplot's by keyword and datashader.#1238JelmerBot wants to merge 2 commits intoholoviz:mainfrom
by keyword and datashader.#1238Conversation
Shows categorical legend when hvplot's `by='column'` keyword is used with datashader enabled. Now results in the same output as `aggregator=ds.count_cat('columns')`.
|
Hi @JelmerBot, sorry I took so long to come back to you! And thanks for opening a PR :) I checked the effects of your changes on the code you shared and the results look good at first glance. With the changes as of b098ea3: However, I noticed that setting I need to spend a bit more time trying to understand the various things at stake here (likely related to more or less recent developments in HoloViews too). Once it's clearer in my mind, I'll offer you to keep working on the PR, for instance it will require some unit tests. |
|
Hi @maximlt, thanks for looking at my PR! I indeed overlooked the I chose to avoid creating overlays when using datashader, because that was simpler than trying to figure out the legend-creation code. In addition, it leaves all categorical blending to datashader. So, updating the logic to something like this would work: if self.by and (self.subplots or not self.datashade):
obj = Dataset(data, self.by+kdims, vdims).to(element, kdims, vdims, self.by, **params)
if self.subplots:
obj = obj.layout(sort=False)
else:
obj = obj.overlay(sort=False)
else:
obj = element(data, kdims, vdims, **params)Another change is needed to make the Lines 1318 to 1333 in 95e39e7 For example, Regarding unit tests for this PR, can you give me some pointers how to tackle those? Are there already tests for legend creation in hvplot? |



Currently using hvplot with datashader and the
bykeyword does not show a legend. This PR makes thebykeyword behave as if only a categorical aggregator was specified when datashader is used, ensuring a legend is created.A small example where the change is effective: