Reputation: 641
I want to plot a 2D array 3298x9896 named IR
over a world map, that is the world planisphere (you can see Africa on the left):
Now I need to overplot a filling in world map grid. I usually make use of map
to create a projected world grid with continents and it works fine:
fig = plt.figure(figsize=(18,9))
map = Basemap(projection='cyl', lat_0 = 57, lon_0 = -135, resolution = 'c', area_thresh = 0.1, llcrnrlon=0.0, llcrnrlat=-60.0, urcrnrlon=360.0, urcrnrlat=60.0)
map.drawcoastlines()
map.drawcountries()
map.drawparallels(np.arange(-90,90,15.0),labels=[1,1,0,1])
map.drawmeridians(np.arange(-180,180,15),labels=[1,1,0,1])
map.drawmapboundary()
But if now I try to overplot the array data:
fig = plt.imshow(IR)
I get the attached picture, that seems incomplete and doesn't fill in the map. Now, except for the colors, what am I doing wrong? Thanks in advance.
Upvotes: 1
Views: 1682
Reputation: 6194
You should use the Basemap instance map
for imshow
:
fig = map.imshow(IR)
to make sure the projection is used. The example below uses random data, but works correctly
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure(figsize=(18,9))
map = Basemap(projection='cyl', lat_0 = 57, lon_0 = -135, resolution = 'c', area_thresh = 0.1, llcrnrlon=0.0, llcrnrlat=-60.0, urcrnrlon=360.0, urcrnrlat=60.0)
map.drawcoastlines()
map.drawcountries()
map.drawparallels(np.arange(-90,90,15.0),labels=[1,1,0,1])
map.drawmeridians(np.arange(-180,180,15),labels=[1,1,0,1])
map.drawmapboundary()
IR = np.random.rand(3298, 9896)
map.imshow(IR)
Upvotes: 1