From: Michael Droettboom <mdroe@st...>  20080918 06:16:30

It seems you're getting bitten by the braindead interpolation of points (which is meant to draw line segments as curves that follow the radii). I have fixed the polar drawing code in SVN r6106 to normalize theta to (0.0 <= theta <= 2pi) before doing the interpolation, which seems to fix your example. The user doesn't/shouldn't have to care about whether theta is negative. Cheers, Mike jan gillis wrote: > Hi Tony, > > Thank you for the reply, the solutions you propose are fine in this > case. But I'm trying to use the polar plot > as a smith chart for an instrument and there i will receive data that is > unknown but can be something like this: > > r = np.transpose(.1+np.arange ( 0 , 0.7 , 0.001)) > theta = 4.5 * np.pi *r > freq = r*10e9 > data = np.multiply(r,np.exp(1j*theta)) > ax.plot(angle(data),abs(data)) > > Any idea why Polar plot can't handle theta going from negative to > positive radians? > > Jan > > Tony S Yu wrote: > >> On Sep 17, 2008, at 1:59 AM, jan gillis wrote: >> >> >>> Hello, >>> >>> I have a problem with polar plot, if i run the following code in >>> matplotlib 0.98.3, polar plot is drawing a extra circle to go from >>> angle 3.14159265 to angle 3.03753126. Is there a solution for this >>> problem? >>> >>> ******************** >>> import numpy as np >>> from matplotlib.pyplot import figure, show, rc, grid >>> >>> # radar green, solid grid lines >>> rc('grid', color='#316931', linewidth=1, linestyle='') >>> rc('xtick', labelsize=15) >>> rc('ytick', labelsize=15) >>> >>> # force square figure and square axes looks better for polar, IMO >>> fig = figure(figsize=(8,8)) >>> ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True, axisbg='#d5de9c') >>> >>> z = np.zeros((1,2000),complex) >>> z.real = 0.2 >>> z.imag = np.arange(50,50,0.05) >>> gamma_r = np.transpose((z1)/(z+1)) >>> >>> ax.plot(np.angle(gamma_r), np.abs(gamma_r), '.', zorder=0) >>> >> Hi Jan, >> >> It looks like you get the circle because the angles you're plotting go >> from negative to positive radians in a weird way. The circle being >> drawn starts around 0 radians and goes clockwise by negative values. >> Then when it gets to  pi, it switches to positive indices, i.e. pi. >> Of course, these are the same points on a polar plot, but different >> angles, if you want to be consistent. >> >> Here are a couple of quick solutions, but there but there maybe better >> ways of handling this. >> >> # ~~~~~~~~~~~~~~~~~~ >> # get rid of the plot line above, and add the following >> theta = np.angle(gamma_r) >> mag = np.abs(gamma_r) >> >> # option 1 >> ordered = np.argsort(theta, axis=0).squeeze() >> ax.plot(theta[ordered], mag[ordered], '.', zorder=0) >> >> # option 2 >> neg_theta = np.where(theta < 0) >> theta[neg_theta] += 2 * np.pi >> ax.plot(theta, mag, '.', zorder=0) >> # ~~~~~~~~~~~~~~~~~~ >> >> I hope that's helpful, >> Tony >> >> >>> ax.set_rmax(2.0) >>> grid(True) >>> >>> show() >>> >>> ******************** >>> Kind regards, >>> Jean >>> >>> >>>  >>> >>> This SF.Net email is sponsored by the Moblin Your Move Developer's >>> challenge >>> Build the coolest Linux based applications with Moblin SDK & win >>> great prizes >>> Grand prize is a trip for two to an Open Source event anywhere in the >>> world >>> http://moblincontest.org/redirect.php?banner_id=100&url=/ >>> _______________________________________________ >>> Matplotlibusers mailing list >>> Matplotlibusers@... >>> https://lists.sourceforge.net/lists/listinfo/matplotlibusers >>> >> > >  > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblincontest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Matplotlibusers mailing list > Matplotlibusers@... > https://lists.sourceforge.net/lists/listinfo/matplotlibusers >  Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA 