도형 생 성(matplotlib.patches)

#  :http://blog.csdn.net/you_are_my_dream/article/details/53458443
#fill=False     ,linewidth=2    ,linestyle    
#!/usr/bin/python
#coding: utf-8

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches

fig, ax = plt.subplots()

#       
xy1 = np.array([0.2, 0.2])
#       
xy2 = np.array([0.1, 0.7])
#       
xy3 = np.array([1.0, 0.2])
#      
xy4 = np.array([1.0, 0.8])
#       
xy5 = np.array([0.6, 0.6])

#           
circle = mpatches.Circle(xy1, 0.1, color = "r")
ax.add_patch(circle)

#                 
rectangle = mpatches.Rectangle(xy2, 0.2, 0.2, color= "g")
ax.add_patch(rectangle)

#         ,           
polygon1 = mpatches.RegularPolygon(xy3, 5, 0.1, color= "y")
ax.add_patch(polygon1)

#     ,            ,       
#   ,   
ellipse = mpatches.Ellipse(xy4, 0.4, 0.2, color= "b")
ax.add_patch(ellipse)

polygon2 = mpatches.RegularPolygon(xy5, 6, 0.2, color= "c")
ax.add_patch(polygon2)

#          x  y    
ax.axis("equal")

#     
ax.grid()

plt.show()

좋은 웹페이지 즐겨찾기