Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matplotlib:plot a line closed

I plot a figure as below:

plt.plot(lon,lat,'ro-')
plt.show()

enter image description here

but the lines aren't closed. How can I make them closed as polygons? thank you

like image 854
wuwucat Avatar asked May 09 '13 19:05

wuwucat


1 Answers

Use matplotlib.pyplot.fill(lon,lat,fill=False) instead of plot().

See http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.fill for details. The color string refers to the interior, so to use red for the polygon, use

plt.fill(lon, lat, edgecolor='r', fill=False)

and continue to use plot() to place circles on the vertices if desired.

like image 102
Bennett Brown Avatar answered Oct 18 '22 12:10

Bennett Brown