Setting opacity for unselected points outside the marker

When I select a point in a scatter plot I want all the other unselected points to have a low opacity but without showing the density effect (i.e. non accumulative)

In a normal plot setting the opacity outside the marker achieves this but unselected doesn’t have an opacity attribute.

Is there any other way?

Thanks

Hi @sabri, welcome to the forum! I think what you want to decrease is not the opacity (which will let the other markers show through it), but the saturation of the color (as in HSV colors). You can pass plotly colors as hsv strings (eg 'hsv(0,100%,100%)') so you could just decrease the saturation of non-selected points.

@sabri See a previous discussion on this forum https://community.plotly.com/t/selected-points/12596 and a link to a notebook on setting color of selected points and opacity of the non-selected ones.

Thanks Emmanuelle, but hsv in my case is not different from rgb.
This is basically what I am trying to achieve:

I’ve done this by having two plots:

  1. a plot of the unselected points with opacity 0.1 (defined outside the marker)

  2. another plot with selected points drawn on top to avoid overlapping

It is not efficient and a bit slower but that is what I can manage

This is what happens when I use unselected.marker.opacity=0.1:

The problem with hsv or rgb is that the selectedpoints are sometimes buried under the unselected ones and can sometimes be barely seen

I am using the plots in Dash btw.

the links are down unfortunately. Could you by any chance repost this?

I moved the notebooks to trash because they were posted long time ago, and the oldest ones contain code with outdated plotly syntax. When someone complains that a notebook at a link posted here is missing, I download and run it to see if it works, eventually I make the necessary changes. I don’t have the time to do that with all notebooks posted years in a row.
Now you can access it at he same link: https://chart-studio.plotly.com/~empet/14975

Add fw.show() after each figurewidget, fw, definition.

1 Like