I'm using a path to define a custom marker for a plot using the matplotlib package. In addition, I need to be able to rotate the marker to show direction.
I followed this example, and the marker rotates. However, depending on the angle, the size of the marker changes.
Here is the code I am using:
import matplotlib.pyplot as plt
from matplotlib.path import Path
from matplotlib import transforms
import matplotlib.patches as patches
fig = plt.figure(figsize=(10, 5))
ax = fig.add_subplot(1, 1, 1)
ax.set_xlim(-10, 10)
ax.set_ylim(-4, 4)
colors = ax.set_prop_cycle(color = ['#993F00', '#0075DC'])
triangle = Path([[-1.,-1.], [1., -1.], [0., 2.], [0.,0.],], [Path.MOVETO, Path.LINETO, Path.LINETO,
Path.CLOSEPOLY,])
print("First Triangle:", triangle, type(triangle))
#patch1 = patches.PathPatch(triangle, facecolor='orange', lw=2)
line1, = ax.plot(0, 0, marker=triangle, markersize=50, alpha=0.5)
R = transforms.Affine2D().rotate_deg(45)
triangle = triangle.transformed(R)
#patch2 = patches.PathPatch(triangle, facecolor='blue', lw=2)
line2, = ax.plot(0, 0, marker=triangle, markersize=50, alpha=0.5)
print("\n transform R", R)
print("\ntriangle after transform", triangle, type(triangle))
#ax.add_patch(patch1)
#ax.add_patch(patch2)
plt.show()
The commented out lines convert the path to patches (incidentally, if anyone is willing to explain what a patch is vs a path, I'd be grateful) to show that the transformation on the underlying path works fine, it just warps size when you plot it.
This is the output of the current program:

Thank you!
