question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using linked selection removes alpha coloring

See original GitHub issue

Description 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): without link_selections
  • With link_selections (brushing is possible, alpha is reset): with link_selections

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:open
  • Created 2 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
peterroelantscommented, Jul 24, 2021

@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 to link_selections.instance() or link_selections constructor, which calls .instance(). .instance() has a **params argument that passes all keyword arguments along to the ParameterizedFunction 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 the element at this place. I had a look and couldn’t find any alpha parameter on the element.

If we want to support selected_alpha and unselected_alpha parameters then I think we also have to modify the _Styles stream, which seems to carry the unselected_alpha setting alpha=inst.unselected_alpha . This stream is further passed in as the selection_streams variable to OverlaySelectionDisplay.build_selection(), where this selection stream is further applied to the layer via OverlaySelectionDisplay._apply_style_callback(). It’s in this last method that the alpha value is being overwritten with alpha = 1 if the layer is not the first layer.

I might work on a PR updating _Styles sometime in the future.

0reactions
matthieugross-bibcommented, Oct 28, 2021

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found