Skip to content
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

vector_to_opacity - dyn not working as expected or not intuitive #98

Open
cboulay opened this issue Jun 4, 2021 · 0 comments
Open

vector_to_opacity - dyn not working as expected or not intuitive #98

cboulay opened this issue Jun 4, 2021 · 0 comments

Comments

@cboulay
Copy link

cboulay commented Jun 4, 2021

docstring:

dyn : tuple | (0., 1.)
Minimum and maximum of the transparency levels.

relevant code:

xtr_min = max(dyn[0] * _data.min() / clim[0], 0.) if clim[0] != 0. else 0.
xtr_max = min(dyn[1] * _data.max() / clim[1], 1.) if clim[1] != 0. else 0.

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])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant