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

Is there a way to have the lowest alpha class visible? #138

Open
Babakjfard opened this issue Jul 29, 2021 · 4 comments
Open

Is there a way to have the lowest alpha class visible? #138

Babakjfard opened this issue Jul 29, 2021 · 4 comments
Labels
discussion space for collecting ideas and discuss these

Comments

@Babakjfard
Copy link

Babakjfard commented Jul 29, 2021

My question is not a bug that may require fixing. Simply, I want to know if there is a way to prevent alpha makes complete fade out or 100% transparency? therefore prevent all polygons on first class will be invisible on the map. Am I losing something? Is there anyway that I can tell vba_choroplet to start from already second level, so that I can still see the values?
Thank you for your help.

@Babakjfard
Copy link
Author

I solved the problem this way.
In file _viz_value_by_alpha_mpl.py I added this line inside value_by_alpha_cmap function after line 103:

rgba[:, 3] = np.maximum(rgba[:, 3], 0.1)

I think the best approach would be to add an optional value for minimum alpha when calling vba_choropleth and default be 0.

I think it would be good if you add this option. I can help with that by creating a new branch and send a pull request, if you consider adding this capability.

@slumnitz
Copy link
Member

slumnitz commented Aug 3, 2021

Hello @Babakjfard, thank you for reporting this behaviour and suggesting this option! I agree it would be useful to add logic that allows to scale the alpha value used, or to display values better in certain bins.

I imagine two options:

A) the distribution of values in the rgbA array is currently normalised between 0 & 1, maybe another normalisation method would be better suited (i.e. custom between 0.1 & 1)

B) to introduce a threshold as suggested by @Babakjfard for low values.

I think the how to might need some discussion in the wider community, what are your thoughts @ljwolf @darribas @sjsrey ?

@slumnitz slumnitz added the discussion space for collecting ideas and discuss these label Aug 3, 2021
@martinfleis
Copy link
Member

A) the distribution of values in the rgbA array is currently normalised between 0 & 1, maybe another normalisation method would be better suited (i.e. custom between 0.1 & 1)

I can imagine similar keywords geopandas uses to normalise the colormap (vmin, vmax) so you can control this directly (both ends).

We could also reconsider the default behaviour here, I am not sure if the current one with alpha=0 is the best one.

@ReichYang
Copy link

I solved the problem this way. In file _viz_value_by_alpha_mpl.py I added this line inside value_by_alpha_cmap function after line 103:

rgba[:, 3] = np.maximum(rgba[:, 3], 0.1)

I think the best approach would be to add an optional value for minimum alpha when calling vba_choropleth and default be 0.

I think it would be good if you add this option. I can help with that by creating a new branch and send a pull request, if you consider adding this capability.

Hi I encountered the same problem and used your method! It worked on the map but the legend is not reflecting the change and the first column is still transparent. Do you know anyway I can edit the legend?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion space for collecting ideas and discuss these
Projects
None yet
Development

No branches or pull requests

4 participants