Is it possible to control matplotlib marker orientation?

phasselmann picture phasselmann · Apr 28, 2014 · Viewed 9k times · Source

I would like to know if I have a triangular marker, is it possible to control its orientation? I have a series of facets, with their corresponding vertices, and I would like to plot a basemap of them. I know it is straight forward script when using Mayavi and tvtk.PolyData. But since I'm dealing with maps and not 3D objects, things got a bit complicated.

ps: for maps I'm using basemap tool.

I thanks for any help.

Answer

Ffisegydd picture Ffisegydd · Apr 28, 2014

You can create custom polygons using the keyword argument marker and passing it a tuple of 3 numbers (number of sides, style, rotation).

To create a triangle you would use (3, 0, rotation), an example is shown below.

import matplotlib.pyplot as plt

x = [1,2,3]
for i in x:
    plt.plot(i, i, marker=(3, 0, i*90), markersize=20, linestyle='None')

plt.xlim([0,4])
plt.ylim([0,4])

plt.show()

Plot