python draw polygon

Solutions on MaxInterview for python draw polygon by the best coders in the world

showing results for - "python draw polygon"
Marlon
08 Nov 2019
1# credit to the Stack Overflow user in the source link
2
3import matplotlib.pyplot as plt
4
5coord = [[1,1], [2,1], [2,2], [1,2], [0.5,1.5]]
6coord.append(coord[0]) # repeat the first point to create a 'closed loop'
7
8xs, ys = zip(*coord) # create lists of x and y values
9
10plt.figure()
11plt.plot(xs,ys) 
12plt.show()