Dear All, I am not very much into matplotlib, so please bear with me if I am asking a trivial question. I put together this small snippet with the help I got on the mailing list and using the arrow example at
http://bit.ly/cI9dqj . My problem is (or at least I believe it to be) the fact that I am messing up the coordinates or rather: I am generating a x and y coordinates in the range [-1,1], but I eventually resort to polar coordinates. It all goes fine till I try adding arrows to the image (then I think about Cartesian coordinates) and the result is quite a mess. Bottom line: any ideas about how to use arrows in a polar plot? Many thanks Lorenzo ########################################################################## #!/usr/bin/env python """ See pcolor_demo2 for a much faster way of generating pcolor plots """ from __future__ import division from pylab import * # make these smaller to increase the resolution dx, dy = 0.005, 0.005 x = arange(-1.0, 1.0, dx) y = arange(-1.0, 1.0, dy) X,Y = meshgrid(x, y) # function defined in polar coordinate def func5(theta, r): y = r*np.sin(theta) theta=np.arcsin(y) return np.cos(theta) def func6(theta, r): y = r*np.sin(theta) theta=np.arcsin(y) return np.abs(sin(theta)) def func7(theta, r): y = r*np.sin(theta) theta=np.arcsin(y) return np.abs(cos(theta)) R=1. n_theta, n_r = 360, 100 # coordinates of the mesh theta = np.linspace(0, 2*np.pi, n_theta+1) r = np.linspace(0., R, n_r + 1) dr, dtheta = r[1]-r[0], theta[1]-theta[0] # cooridnate for the data point theta_d = np.arange(dtheta/2., 2*np.pi, dtheta) r_d = np.arange(dr/2., R, dr) TT, RR = meshgrid(theta_d, r_d) # Z = func6(TT, RR) Z = func7(TT, RR) ax=subplot(1,1,1, projection="polar", aspect=1.) ax.pcolormesh(theta, r, Z) # ax.set_xlabel('Model complexity --->') ax.set_yticklabels([]) ax.set_xticklabels([]) ax.grid(False) # show() arr = Arrow(0, 0, .3, .3, edgecolor='white') # Get the subplot that we are currently working on ax = gca() # Now add the arrow ax.add_patch(arr) # We should be able to make modifications to the arrow. # Lets make it green. arr.set_facecolor('g') savefig("test.pdf") clf() ------------------------------------------------------------------------------ Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users