Hello,
How complicated would it be to obtain the add_patch() capability in polar axes? Right now, the script
···
--------------------
from pylab import *
import matplotlib.patches as patches
ax = axes( [0.1, 0.1, 0.8, 0.8], polar = True )
ptch = patches.RegularPolygon( (pi/2,.5), 5, orientation = 20 )
ax.add_patch()
show()
--------------------
fails, Python complaining that polar axes don't have an add_patch() method.
Now, I believe if we simply mimic what's in the Axes class and try to use
artists.extend(patches)
in PolarAxes, the coordinates are going to be all wacko.
The following works for me, and I wonder whether it is a useful addition to PolarAxes (sorry for the wrapped lines):
--------------------
from matplotlib.pylab import *
def RegularPolygon_polar( ax, xy, numVertices, radius = 5, orientation = 0, **kwargs ):
import matplotlib.patches as patches
import matplotlib.transforms as transforms
ptch = patches.RegularPolygon( (0,0),
numVertices,
radius = radius,
orientation = orientation,
**kwargs )
trans = transforms.identity_affine()
trans.set_offset( xy, ax.transData )
ptch.set_transform( trans )
return ptch
ax = axes( [0.1, 0.1, 0.8, 0.8], polar = True )
ptch = RegularPolygon_polar( ax, (150*pi/180,.5), 5, radius = 10, orientation = 80 )
ax.add_patch( ptch )
show()
--------------------
If this sounds like the way to go, let me know. I'm willing to write the few methods similar to the above and add them to PolarAxes.
On the other hand, it might be easier to simply modify the classes in patches.py, but I am not sure how they would access the Axes instance.
Cheers,
Dominique