matplotlib / matplotlib/basemap
pcolormesh plot is blank; pcolor plot works
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 817
- Forks
- 395
- PR merge metrics
- No merged PRs in 30d
Description
I am experiencing strange behavior using mpl_toolkits.basemap.Basemap.
My understanding is that pcolormesh is faster than pcolor, and thus
preferable. Here is a minimal example (below) where I get a different
plot from pcolormesh than from pcolor.
On two systems (mac os x 10.9.5; Ubuntu 11.04 (GNU/Linux 2.6.32.28
x86_64); basemap 1.0.7 on the mac and 1.0.8 on the Ubuntu machine; both
using matplotlib 1.4.2) I get the expected grid of random colors from
pcolor, but a monochrome plot from pcolormesh.
Is this expected? Are there circumstances in which I should be using
pcolor instead of pcolormesh? Is this a bug in matplotlib or in
basemap?
``` python
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
import numpy as np
def setup_map(ax):
m = Basemap(width=8.0e6,
height=6.5e6,
projection='aeqd',
lat_0=54,
lon_0=-105,
resolution='l',
area_thresh=1000,
rsphere=6371007.181000,
fix_aspect=True,
ax=ax)
m.drawcoastlines()
m.drawcountries()
m.drawstates()
return(m)
# create pseudo-data with longitudes and latitudes
lon, lat = np.meshgrid(np.arange(-180, 180),
np.arange(90, -90, -1))
data = np.random.rand(*lon.shape) * 100
# two-panel figure
fig, ax = plt.subplots(nrows=1, ncols=2)
# plot pseudodata in left panel using pcolormesh
m0 = setup_map(ax[0])
cm = m0.pcolormesh(lon, lat, data, latlon=True,
vmin=0.0, vmax=100.0, cmap=plt.cm.get_cmap("Blues"))
plt.colorbar(cm, ax=ax[0])
ax[0].set_title('pcolormesh')
# plot pseudodata in left panel using pcolor
m1 = setup_map(ax[1])
cm = m1.pcolor(lon, lat, data, latlon=True,
vmin=0.0, vmax=100.0, cmap=plt.cm.get_cmap("Blues"))
plt.colorbar(cm, ax=ax[1])
ax[1].set_title('pcolor')
plt.show()
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied minimal Python example and compare Basemap.pcolormesh(..., latlon=True) with Basemap.pcolor(..., latlon=True) using the reported projection and data. Determine whether the blank or monochrome result is expected, and whether the needed change belongs in Basemap or matplotlib; done means the behavior is explained and a reproducible fix or clear upstream diagnosis is established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100