matplotlib / basemap

Plot on map projections (with coastlines and political boundaries) using matplotlib
MIT License
772 stars 390 forks source link

Any way to control shapefile alpha? #584

Closed guidocioni closed 11 months ago

guidocioni commented 11 months ago

The readshapefile method does not have the capability of passing an alpha keyword argument as all other methods.

Is there any way to control the opacity of the lines drawn by the readshapefile method?

molinav commented 11 months ago

Hi @guidocioni! I was looking at the code and in effect the alpha argument is not available in readshapefile. However, I was testing with the underlying LineCollection call inside readshapefile and of course this is possible, so the limitation comes from the basemap side.

Maybe it is a good idea to include it for basemap 1.4.0 so that it is more user-friendly. In the meantime, one workaround for you would be to provide the color argument as a 4-value tuple, e.g. (R, G, B, A), where A is the opacity. The four values should be between 0 and 1.

guidocioni commented 11 months ago

yeah, few minutes after opening the issue I realized you can pass a rgba array as color so it was easy to change the alpha there. I don't think there's any need to introduce an alpha keyword argument If you can control the alpha in the color