## matplotlib-users

 [Matplotlib-users] Basemap and imshow From: Tommy Grav - 2008-03-06 16:03:03 ```Is there a way of using imshow together with a basemap? Cheers Tommy ```
 Re: [Matplotlib-users] Basemap and imshow From: Jeff Whitaker - 2008-03-06 16:11:22 ```Tommy Grav wrote: > Is there a way of using imshow together with a basemap? > > Cheers > Tommy > Tommy: Use the imshow basemap method, just as you would the pylab version. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449 325 Broadway Boulder, CO, USA 80305-3328 ```
 Re: [Matplotlib-users] Basemap and imshow From: Tommy Grav - 2008-03-06 16:49:42 ```Thanks for pointing this function out. I thought I had look for it, but must have overlooked it. I am using the test code below, but the array is plotted outside the boundary of the map. Is there a way to avoid this? Cheers Tommy from math import * from matplotlib.toolkits.basemap import Basemap import pylab import numpy rabins = numpy.arange(0.,360.,6) decbins = numpy.arange(-90.,90.,6) map = Basemap(projection="sinu",lat_0=0.,lon_0=180.,rsphere=1.) coverage = numpy.zeros([len(decbins),len(rabins)],"int") coverage[0:5,:] = 2 coverage[5:10,:] = 4 map.imshow(coverage,interpolation="nearest",cmap=pylab.cm.hot_r) map.drawmapboundary() pylab.show() On Mar 6, 2008, at 11:10 AM, Jeff Whitaker wrote: > Tommy Grav wrote: >> Is there a way of using imshow together with a basemap? >> >> Cheers >> Tommy >> > Tommy: > > Use the imshow basemap method, just as you would the pylab version. > > -Jeff > > -- > Jeffrey S. Whitaker Phone : (303)497-6313 > NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449 > 325 Broadway Boulder, CO, USA 80305-3328 > ```
 Re: [Matplotlib-users] Basemap and imshow From: Jeff Whitaker - 2008-03-06 17:06:00 ```Tommy Grav wrote: > Thanks for pointing this function out. I thought I had look for it, > but must have overlooked it. > > I am using the test code below, but the array is plotted outside the > boundary of the map. Is there > a way to avoid this? > > Cheers > Tommy > > from math import * > from matplotlib.toolkits.basemap import Basemap > import pylab > import numpy > > rabins = numpy.arange(0.,360.,6) > decbins = numpy.arange(-90.,90.,6) > map = Basemap(projection="sinu",lat_0=0.,lon_0=180.,rsphere=1.) > > coverage = numpy.zeros([len(decbins),len(rabins)],"int") > > coverage[0:5,:] = 2 > coverage[5:10,:] = 4 > > > map.imshow(coverage,interpolation="nearest",cmap=pylab.cm.hot_r) > map.drawmapboundary() > > pylab.show() > > > > > On Mar 6, 2008, at 11:10 AM, Jeff Whitaker wrote: > > >> Tommy Grav wrote: >> >>> Is there a way of using imshow together with a basemap? >>> >>> Cheers >>> Tommy >>> >>> >> Tommy: >> >> Use the imshow basemap method, just as you would the pylab version. >> >> -Jeff >> >> Tommy: You're using a non-rectangular map projection, so imshow won't work. Try pcolor or pcolormesh instead, i.e. replace map.imshow with: rabins, decbins = numpy.meshgrid(rabins, decbins) x,y = map(rabins,decbins) map.pcolor(x,y,coverage,cmap=pylab.cm.hot_r) -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449 325 Broadway Boulder, CO, USA 80305-3328 ```