matplotlib / basemap

Plot on map projections (with coastlines and political boundaries) using matplotlib

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Any way to control shapefile alpha?

guidocioni opened this issue · comments

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?

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.

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