I'm using a matplotlib Path object to create a custom plotting marker as described here. I'd like to rotate the resulting path about its center by an arbitrary angle. Any suggestions on how to do this would be greatly appreciated.
Here's the code I'm using to create and plot the custom marker
import matplotlib.path
import matplotlib.pylab as plt
def getCustomMarker():
verts = [( -5 , -15 ),
( -5 , -5 ),
( -15 , -5 ),
( -15 , 5 ),
( -5 , 5 ),
( -5 , 15 ),
( 5 , 15 ),
( 5 , 5 ),
( 15 , 5 ),
( 15 , -5 ),
( 5 , -5 ),
( 5 , -15 ),
( -5 , -15 )]
verts = verts
codes = [matplotlib.path.Path.MOVETO,
matplotlib.path.Path.LINETO,
matplotlib.path.Path.LINETO,
matplotlib.path.Path.LINETO,
matplotlib.path.Path.LINETO,
matplotlib.path.Path.LINETO,
matplotlib.path.Path.LINETO,
matplotlib.path.Path.LINETO,
matplotlib.path.Path.LINETO,
matplotlib.path.Path.LINETO,
matplotlib.path.Path.LINETO,
matplotlib.path.Path.LINETO,
matplotlib.path.Path.CLOSEPOLY]
path = matplotlib.path.Path(verts, codes)
return path
plt.scatter([0,0],[0,0], marker=getCustomMarker(), s=5000)
plt.show()
This is what I get:

This is the change I'd like to affect:

You could call the transformed method on your path object with a rotational transform.
import matplotlib as mpl
marker = getCustomMarker()
marker = marker.transformed(mpl.transforms.Affine2D().rotate_deg(45))
plt.scatter([0,0],[0,0], marker=marker, s=5000)
plt.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With