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:  Another option might be to use pcolor, it does work wit polar axes.


import pylab
# make color-filled plot of polar coordinate data array.
# define coordinates.
theta = pylab.linspace(0.,2.*pylab.pi,101)
R = pylab.linspace(0.,pylab.pi,101)
Y,X = pylab.meshgrid(R, theta)
# data to plot.
Z = pylab.sin(Y)*pylab.sin(4*X) + pylab.exp(-(Y**2/4))
# create subplot.
ax = pylab.subplot(111,polar=True)
# mesh fill.
ax.pcolormesh(X,Y,Z)
# make sure aspect ratio preserved
ax.set_aspect('equal')
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