ploting filled polygons in python ploting filled polygons in python python python

ploting filled polygons in python


I'm not exactly sure what matlab does, but you can draw a polygon using matplotlib.patches.Polygon. Adapted from an example in the docs:

import numpy as npimport matplotlib.pyplot as pltimport matplotlibfrom matplotlib.patches import Polygonfrom matplotlib.collections import PatchCollectionfig, ax = plt.subplots()patches = []num_polygons = 5num_sides = 5for i in range(num_polygons):    polygon = Polygon(np.random.rand(num_sides ,2), True)    patches.append(polygon)p = PatchCollection(patches, cmap=matplotlib.cm.jet, alpha=0.4)colors = 100*np.random.rand(len(patches))p.set_array(np.array(colors))ax.add_collection(p)plt.show()

enter image description here