Here's an attempt at adding a method to allow controlling of the maximum radial value displayed in a polar plot. In axes.py, I added the following method to the PolarAxes class. I basically copied the code from autoscale_view() and made some minor changes. If I can figure out what each step actually does I'll add some comments.
def set_rmax( self, rmax ):
rmin, oldrmax = self.rlocator.autoscale()
self.axesPatch.xy = zip(self.thetas, rmax*ones(self.RESOLUTION))
val = rmax*math.sqrt(2)
# Re-create the radial ticks and labels.
ticks = self.rlocator()
for t in self.thetagridlabels:
r = linspace(0, rmax, self.RESOLUTION)
for l in self.thetagridlines:
It sorta works but it definitely has a lot of problems. Here's a sample script:
from pylab import *
figure( figsize=( 5, 5 ) )
theta = arange( 1, 6, .1 )
r = 10 * theta
polar( theta, r )
gca().set_rmax( 30 )
1) I don't really want to call set_rgrids() because you lose any modifications the user has made to the radial grid. If I don't call this, the radial grid doesn't update though so it looks crazy. What would be nice is to duplicate the behavior of X/Y plots. For example, if I set x ticks to be at 1,2,3 and then set the x limit to be 1->2, I don't see the 3 tick somewhere off to the right of the plot.
2) There seems to be some kind of update problem w/ the theta labels. Even though they're locations are being reset in the set_y() call, they don't appear. However, if I use the pan button in the GUI and lightly tap the screen, they'll show up in the right locations (forget for a moment that panning is kind of a stupid thing to do in polar plots).
3) There is definitely some kind of data clipping problem. The curve is not being properly clipped at the plot boundaries after calling set_rmax().
I'm sure all of these are problems w/ my set_rmax() routine but I'm not sure where to start with them. Does anyone have any pointers for me to start with?