-
Notifications
You must be signed in to change notification settings - Fork 14
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 shapes outlines and fill_alpha documentation #367
Comments
Thanks for reporting. I comment on 3. Could you please link the two code places where the |
Sure: spatialdata-plot/src/spatialdata_plot/pl/render.py Lines 256 to 261 in febd424
spatialdata-plot/src/spatialdata_plot/pl/render.py Lines 277 to 279 in febd424
I think the problem is inherent to the way we render: first, create an image using datashader and then render it as if it was a SpatialImage. These 2 steps lead to fill_alpha being used twice, so I'd say it's not a datashader bug. If we set the second one to 1, we get the problem again that the shapes will not look transparent if sth else, e.g. an image was rendered before them. See below (e.g. the triangles are not see-through anymore) |
Thanks, clear now. I'd keep things like this for the moment and merge the PR, and think about this later on. I think the problem can be formulated as follows: consider an image Probably one can find a function The above shows that using |
I was lazy to do the math, so I gave a try to the new o1-preview from ChatGPT. It gives the following (I checked the calculations and they are correct): spatialdata-plot/src/spatialdata_plot/pl/render.py Lines 277 to 279 in febd424
Please note that the assumption is that the image produced by datashader has RGB values between 0 and 1, if not, it should be first scaled. If the datashader image has an alpha channel, maybe the formula would not work and we need to adjust the formulation of the problem and find the formula for the new version of the problem. |
I think I got you, thanks for the input! Brain dump from my side: shouldn't the datashader redering rather be Does that make any sense? |
Yes, this would be the case with |
Status after #309, just to document some thoughts/details about the comparison between ds and mpl:
fill_alpha
in ds looks lighter than in mpl, even though it's0.5
both times. Reason: in ds, the fill_alpha is applied two times: once during theshade()
step, to make sure elements are blended with each other. Then also during the rendering of the resulting image, to make sure other things that were plotted before still shine through. Possible fix: usesqrt(fill_alpha)
both times. Problem: if sth else is rendered below, it would be obvious that the elements are less transparent than the user would expect (e.g. 0.7 instead of 0.5). That could be confusing.The text was updated successfully, but these errors were encountered: