Is there a way to have the lowest alpha class visible?
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.
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.
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 ?
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.
I solved the problem this way. In file
_viz_value_by_alpha_mpl.pyI added this line insidevalue_by_alpha_cmapfunction after line103: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_choroplethand 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?