Petr Danecek wrote:
> Beautiful! The grid lines must be drawn manually?
>
> On Thu, 2006-12-28 at 13:32 -0700, Jeff Whitaker wrote:
>   
>> Here's a slightly prettier version of my previous example:
>>
>> from pylab import *
>> deltatheta = 2.*pi/100.
>> theta = arange(0.,2.*pi+0.5*deltatheta,deltatheta)
>> R = arange(0.,pi,deltatheta)
>> r,t = meshgrid(R, theta)
>> Z = sin(r)*sin(3.*t)
>> X = r*cos(t)
>> Y = r*sin(t)
>> ax = subplot(111)
>> cs = ax.contourf(X,Y,Z)
>> # make sure aspect ratio preserved
>> ax.set_aspect('equal')
>> # turn off rectangular frame.
>> ax.set_frame_on(False)
>> # turn off axis ticks.
>> ax.set_xticks([])
>> ax.set_yticks([])
>> # draw a circle around the edge of the plot.
>> rmax = max(R)
>> ax.plot(rmax*cos(theta),rmax*sin(theta),'k')
>> title('Polar contours')
>> show()
>>
>>     
>
>   

Petr:  Here's yet another way to do it, using the basemap toolkit.  This 
way you get axis grid lines.

from matplotlib.toolkits.basemap import Basemap
import pylab
theta = pylab.linspace(0.,2.*pylab.pi,101)
R = pylab.linspace(0.,pylab.pi,101)
lat,lon = pylab.meshgrid(R, theta)
Z = pylab.sin(lat)*pylab.sin(4*lon) + pylab.exp(-(lat**2/4))
# convert radial coordinate to latitude, with r=0 being north pole
# and r=rmax being equator.
# convert r and theta to degrees.
lat = (180./pylab.pi)*0.5*lat[::-1,:]
lon = (180./pylab.pi)*lon
m = Basemap(boundinglat=0.,lon_0=0.,resolution=None,projection='npaeqd')
X,Y = m(lon,lat)
CS = m.contourf(X,Y,Z,15)
m.drawparallels(pylab.arange(0,90,20),labels=[1,1,1,1])
m.drawmeridians(pylab.arange(0,360,60),labels=[1,1,1,1])
pylab.show()


-Jeff

-- 
Jeffrey S. Whitaker         Phone : (303)497-6313
NOAA/OAR/CDC  R/PSD1        FAX   : (303)497-6449
325 Broadway                Boulder, CO, USA 80305-3328


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to