Skip to content Skip to sidebar Skip to footer

Changing Transparency Of/remove Contour Lines In Matplotlib

I am using contourf to plot some data but am having trouble when it comes to setting the transparency. I want to be able to set the transparency of both the fill AND the lines, but

Solution 1:

The lines you still see when using antialiased = True are actually not lines but the background that is shining through, since the filled contours do not touch each other.

One very ugly fix could be to plot the same twice but with slightly different levels.

pp1 = m.contourf(longitude, latitude, imagelist[0], 50, cmap='YlOrRd', extend="min", alpha = 0.3, antialiased = True)
pp2 = m.contourf(longitude, latitude, imagelist[0], 55, cmap='YlOrRd', extend="min", alpha = 0.3, antialiased = True)

Note, that you also have to divide the alpha value in half to get the same transparency. You will still see the lines, but not as strong as before.

Post a Comment for "Changing Transparency Of/remove Contour Lines In Matplotlib"