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

Datashader min_alpha not in Holoviews #2108

Mossi8 opened this Issue Nov 9, 2017 · 3 comments


None yet
4 participants
Copy link

Mossi8 commented Nov 9, 2017

Hi, I am new both at Holoviews and Datashader. But I tried to get the same plot that I get using datashader using Holoviews but it is being impossible because the datashade function does not have this min_alpha parameter that is present if I only use datashader function tf.shade.

It is important, since as I zoom in I get only a few bins really intense which mask almost the rest of the image.

Thank you

Code in datashader (part of if):
background = "black"
export = partial(export_image, export_path="export", background=background)
cm = partial(colormap_select, reverse=(background=="black"))

def create_image(x_range, y_range, w=plot_width, h=plot_height):
cvs = ds.Canvas(plot_width=w, plot_height=h, x_range=x_range, y_range=y_range)
agg = cvs.points(data, 'X_coordinate', 'Y_coordinate', ds.count_cat("Gene"))
img = tf.shade(agg, how = "eq_hist", min_alpha = 255)
spread = tf.dynspread(img, threshold = 0.1, max_px = 1, how="over")
return spread

p = base_plot(background_fill_color=background)
InteractiveImage(p, create_image)

Code using Holoviews ():
import numpy as np
import holoviews as hv
import datashader as ds
from holoviews.operation.datashader import aggregate, datashade, dynspread, shade

shade.cmap="#30a2da" # to match HV Bokeh default
data_smFISH = data
data_smFISH["Gene"] = data_smFISH["Gene"].astype("str")
dic_data = {i : hv.Points(data_smFISH[data_smFISH["Gene"].apply(lambda x: x == i)]
[["X_coordinate", "Y_coordinate"]]) for i in data["Gene"].unique()}
Nd = hv.NdOverlay(dic_data, kdims=["Gene"])
agg = datashade(Nd, aggregator=ds.count_cat('Gene'))
dynspread(agg, how = "over")

@philippjfr philippjfr added the feature label Nov 9, 2017


This comment has been minimized.

Copy link

jlstevens commented Nov 9, 2017

Thanks for reporting this.

We should expose as much functionality from datashader as we can so I'm assigning this issue to the next milestone. I don't expect it will take too much effort to support. @philippjfr Can you confirm that there is no easy way to set min_alpha currently?


This comment has been minimized.

Copy link

Mossi8 commented Nov 9, 2017

Yes, I have read through the script and at some point it transforms the RGBA to RGB (as I understood), therefore, there isn't any alpha or min_alpha parameter to optimize. Which practically means that the plot is the same as the equivalent to using datashader with min_alpha = 0.

I have also tried different things, but nothing solved the problem.

Thank you for your time


This comment has been minimized.

Copy link

jbednar commented Nov 9, 2017

Right; this is an omission from holoviews.operation.datashader.shade(), which was probably written before we added min_alpha to datashader. Should be trivial; I'll make a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.