Search code examples
pythonmatplotlibmatplotlib-basemap

Is it possible to control matplotlib marker orientation?


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 straightforward 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.


Solution

  • 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