-
Notifications
You must be signed in to change notification settings - Fork 398
Closed
Description
Hi,
You have already addressed this issue a few years ago here where you said it would be better to use pcolor.
In my case I need the possibility of imshow to use a NxMx3 array as input to explicitly set the colors.
An example of the image I get and some code:
fig = plt.figure(figsize=(10, 18))
ax1 = plt.subplot(211)
m = Basemap(projection='robin',
lon_0=0., ax=ax1)
# Compute lats and lons arrays
lons = (-180. + np.arange(720) / 2.) + 0.25
lats = (-90. + np.arange(360) / 2.) + 0.25
nx = int((m.xmax - m.xmin) / 25000.) + 1
ny = int((m.ymax - m.ymin) / 25000.) + 1
waterf_rp = m.transform_scalar(allf[:, :, 0], lons, lats, nx, ny)
radf_rp = m.transform_scalar(allf[:, :, 1], lons, lats, nx, ny)
tempf_rp = m.transform_scalar(allf[:, :, 2], lons, lats, nx, ny)
allf_rp = np.dstack((waterf_rp, radf_rp, tempf_rp))
# Plot Data
im = m.imshow(np.flipud(allf_rp))
# Add Grid Lines
m.drawparallels(np.arange(-90., 90., 30.), labels=[1, 0, 0, 0], fontsize=10)
m.drawmeridians(np.arange(-180., 180., 60.), labels=[0, 0, 0, 1], fontsize=10)
# Add Coastlines, States, and Country Boundaries
m.drawcoastlines()
m.drawstates()
m.drawcountries()
I also tried to use the keywords masked and checkbounds in the transform_scalar method but they did not change the result.
It seems you already have a solution for the problem in the warpimage routine since the robinson projections works fine with. e.g. bluemarble ?
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
# setup Lambert Conformal basemap.
# set resolution=None to skip processing of boundary datasets.
m = Basemap(projection='robin',
lon_0=0.)
m.bluemarble()
plt.show()
Metadata
Metadata
Assignees
Labels
No labels