matplotlib / matplotlib/basemap

Strange lines appear when using pcolormesh with nonzero alpha value

Open
#480 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
817
Forks
395
PR merge metrics
No merged PRs in 30d

Description

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](https://user-images.githubusercontent.com/9418465/71375327-d5733300-258b-11ea-9b5c-51b8b8646658.png)

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

![test2](https://user-images.githubusercontent.com/9418465/71375338-e2902200-258b-11ea-805c-a5e4a1469848.png)

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied Basemap.pcolormesh example with the Robinson projection, comparing alpha below 1 with alpha=1. Trace the pcolormesh call into the matplotlib rendering path and identify why projected cells produce visible lines during transparency compositing. Done means the reproduced plot has no unintended lines when using nonopaque alpha.

Written by the indexing model from the issue text.

Assessment

Tech stack
matplotlib, python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.