Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageStack support and aggregator fixes #1316

Merged
merged 2 commits into from
Apr 17, 2024
Merged

ImageStack support and aggregator fixes #1316

merged 2 commits into from
Apr 17, 2024

Conversation

maximlt
Copy link
Member

@maximlt maximlt commented Apr 16, 2024

Fixes #1315

With these changes:

  • rasterize=True, by='cat' is equivalent to rasterize=True, aggregator=ds.count_cat('cat')
  • the value of eltype is correctly set to ImageStack when an ImageStack should be returned, so the options are correctly applied to the output of the operation

I've moved the logic that infers whether a datashaded plot is categorical or not and the aggregator to a method that is used in two places.

import datashader as ds
import numpy as np
import pandas as pd
import hvplot.pandas

num=10000

dists = {cat: pd.DataFrame(dict([('x',np.random.normal(x,s,num)), 
                                 ('y',np.random.normal(y,s,num)), 
                                 ('val',val), 
                                 ('cat',cat)]))      
         for x,  y,  s,  val, cat in 
         [(  2,  2, 0.03, 10, "d1"), 
          (  2, -2, 0.10, 20, "d2"), 
          ( -2, -2, 0.50, 30, "d3"), 
          ( -2,  2, 1.00, 40, "d4"), 
          (  0,  0, 3.00, 50, "d5")] }

df = pd.concat(dists,ignore_index=True)
df["cat"]=df["cat"].astype("category")

p = df.hvplot.scatter('x', 'y', rasterize=True, aggregator=ds.count_cat('cat'), width=800)
p

image

@maximlt maximlt merged commit 96c49ec into main Apr 17, 2024
9 checks passed
@maximlt maximlt deleted the fix_aggregator_by branch April 17, 2024 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issues with ImageStack support
1 participant