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

Strange lines appear when using pcolormesh with nonzero alpha value #480

Open
ricitron opened this issue Dec 23, 2019 · 2 comments
Open

Comments

@ricitron
Copy link

When plotting data using pcolormesh on a basemap projection (or a cartopy projection) I notice strange lines appear when I set the alpha value to less than 1.

Example code:

from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt

plt.clf()

dpp =1 # degrees per pixel
lons = np.arange(-180,180+dpp,dpp)
lats = -1*np.arange(-90,90+dpp,dpp)

m = Basemap(projection='robin',lon_0=0)
data = np.random.random((np.size(lats), np.size(lons)))
lons, lats = np.meshgrid(lons, lats)
x, y = m(lons, lats)

im = m.pcolormesh(x, y, x, latlon=False, cmap='RdBu')
#im = m.pcolormesh(lons, lats, data, latlon=True, cmap='RdBu')

m.colorbar(im)
plt.show()

The output shows strange lines appearing:

test1

If I instead set alpha=1 the lines disappear and the behavior is as expected:

test2

Any ideas on what the issue is or how to get pcolormesh to work with a nonzero alpha value?

@efiring
Copy link
Member

efiring commented Dec 23, 2019

This is a known problem referenced in matplotlib/matplotlib#1188 and, I think, more comprehensively in other old matplotlib issues that elude my quick attempt to search for them. We have found no general good solutions.

@pranavsai142
Copy link

pranavsai142 commented May 31, 2024

Any update on this? I am facing an issue graphing gridded data using pcolormesh, Gouraud shading. When I lower the alpha value from 1, I get lines appearing.
ax.pcolormesh(self.mapWindPointsLongitudes, self.mapWindPointsLatitudes, self.mapSpeeds[index], shading='gouraud', vmin=vmin, vmax=vmax, zorder=2)
map_wind_10

This is at alpha=1. However the map disappeared : |
map_wind_0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants