Using linked selection removes alpha coloring
See original GitHub issueDescription of expected behavior and the observed behavior
Using linked selections on between a 2D scatterplot and the derived histogram resets the alpha color options.
- Without
link_selections
(no brushing is possible,alpha
is respected): - With
link_selections
(brushing is possible,alpha
is reset):
Complete, minimal, self-contained example code that reproduces the issue
import numpy as np
import holoviews as hv
hv.extension('bokeh')
color_map = {
'p1': 'navy',
'p2': 'green'
}
points_dct = {
'p1': hv.Points(np.random.randn(1000, 2), kdims=['x', 'y'], label='p1').opts(color=color_map['p1'], alpha=0.2),
'p2': hv.Points(np.random.randn(1000, 2) * 2 + 1, kdims=['x', 'y'], label='p2').opts(color=color_map['p2'], alpha=0.2)
}
nd_overlay = hv.NdOverlay(points_dct, kdims='cat')
hist_dct = {
k: hv.operation.histogram(p, dimension='x').opts(color=color_map[k], alpha=0.5)
for k, p in points_dct.items()
}
hist_nd_overlay = hv.NdOverlay(hist_dct, kdims='cat')
ls = hv.selection.link_selections.instance()
# plot = ls(nd_overlay) + ls(hist_nd_overlay) # Removes "alpha"
plot = hv.selection.link_selections(nd_overlay + hist_nd_overlay) # Removes "alpha"
# plot = nd_overlay + hist_nd_overlay # No slection
plot
ALL software version info
Python version : 3.9.6
bokeh : 2.3.3
holoviews: 1.14.4
numpy : 1.21.0
jupyter core : 4.7.1
jupyter-notebook : 6.4.0
qtconsole : not installed
ipython : 7.25.0
ipykernel : 6.0.1
jupyter client : 6.1.12
jupyter lab : 3.0.16
nbconvert : 6.1.0
ipywidgets : 7.6.3
nbformat : 5.1.3
traitlets : 5.0.5
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Use alpha channels, masks, and mattes in After Effects
Learn about alpha channels that contain transparency information, track mattes, traveling mattes, and feathering masks in After Effects.
Read more >Insanely Difficult Selections MADE EASY with Alpha Channels ...
Learn the power of Masking with Channels in Adobe Photoshop! In this video, you will learn how to use channels to mask fur...
Read more >How do I define or deselect areas where the "Color to Alpha ...
Just use a selection. · Use a paint tool (Brush, usually) in Color Erase mode and paint over the areas that should become...
Read more >Color - PyMOLWiki
Reassigning B-Factors and Coloring ... It is commonplace to replace the B-Factor column of a protein with some other biochemical property at that ......
Read more >iCn3D Help Document - NCBI
In that section, follow the link for Structure - 3D structure displays to open the ... If you then use the "Select >...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jbednar I spend some time looking at the code and I think I know what happens and how to change it.
Where the defaults come from:
The unselected alpha can actually be passed as a custom
unselected_alpha
parameter tolink_selections.instance()
orlink_selections
constructor, which calls.instance()
..instance()
has a**params
argument that passes all keyword arguments along to theParameterizedFunction
base class.If we want to multiply with the original alpha of the plot we probably want to extract the original value at
OverlaySelectionDisplay._apply_style_callback()
. However, I’m not sure myself how I can (and if it’s possible) extract the original alpha value from theelement
at this place. I had a look and couldn’t find anyalpha
parameter on theelement
.If we want to support
selected_alpha
andunselected_alpha
parameters then I think we also have to modify the_Styles
stream, which seems to carry theunselected_alpha
settingalpha=inst.unselected_alpha
. This stream is further passed in as theselection_streams
variable toOverlaySelectionDisplay.build_selection()
, where this selection stream is further applied to the layer viaOverlaySelectionDisplay._apply_style_callback()
. It’s in this last method that the alpha value is being overwritten withalpha = 1
if the layer is not the first layer.I might work on a PR updating
_Styles
sometime in the future.Hello, I’m facing the same “issue” (if we can call it like that). Any progress on how to handle the alpha ? Or at least a workaround?