visbrain
visbrain copied to clipboard
vector_to_opacity - dyn not working as expected or not intuitive
docstring: https://github.com/EtienneCmb/visbrain/blob/b2214ea693cd71e8fd7d894f2c240005831bbdd0/visbrain/utils/color.py#L656-L657
relevant code: https://github.com/EtienneCmb/visbrain/blob/b2214ea693cd71e8fd7d894f2c240005831bbdd0/visbrain/utils/color.py#L685-L686
Let's say we want the opacity to range from 0.5 to 1.0: dyn=(0.5, 1.0)
If clim[0]
is a small number, smaller than _data.min()/2
, then xtr_min
will always be > 1.0. Then the subsequent call to alpha = normalize(_data, xtr_min, xtr_max)
will always return 1.0 for every value.
I think the intended result can be achieved (at least for the 'ascending' case) with something a bit simpler:
alpha = normalize(np.clip(_data, clim[0], clim[1]), dyn[0], dyn[1])