## python matplotlib draw shapes (rectangles, circles, etc.)

B station video: https:? //Www.bilibili.com/video/av6989413/ p = 6

Transfer: https: //www.cnblogs.com/linblogs/p/9672769.html

```import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as mpathes

fig,ax = plt.subplots()
xy1 = np.array([0.2,0.2])
xy2 = np.array([0.2,0.8])
xy3 = np.array([0.8,0.2])
xy4 = np.array([0.8,0.8])
#圆形
circle = mpathes.Circle(xy1,0.05)
#长方形
rect = mpathes.Rectangle(xy2,0.2,0.1,color='r')
#多边形
polygon = mpathes.RegularPolygon(xy3,5,0.1,color='g')
#椭圆形
ellipse = mpathes.Ellipse(xy4,0.4,0.2,color='y')

plt.axis('equal')
plt.grid()
plt.show()```
• Correlation function introduction
• Circle()
• Documentation: https: //matplotlib.org/api/_as_gen/matplotlib.patches.Circle.html#matplotlib.patches.Circle
• Summary: xy of a given radius to create a true circle = (x, y) at
• Attributes
• xy: circular central (property name can be omitted)
• redius: radius of the circle (property name can be omitted)
• For more detailed document attributes
• common problem
• Rectangle()
• Documentation: https://matplotlib.org/api/_as_gen/matplotlib.patches.Rectangle.html#matplotlib.patches.Rectangle
• Introduction: the x, y coordinates to generate a rectangular, (x, y position is the lower left corner of the rectangle)
• Attributes
• xy: a rectangular bottom and left coordinate (property name can be omitted)
• width: rectangle width (attribute name can be omitted, the height and width of the order noted, the second wide)
• height: the height of the rectangle (property name can be omitted, note that the height and width of the order, the third high)
• color: fill color
• For more detailed document attributes
• RegularPolygon()
• Ellipse()