源自:https://blog.csdn.net/petermsh/article/details/78458585
1. 调用包函数绘制圆形Circle和椭圆Ellipse
from matplotlib.patches import Ellipse, Circle
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
ell1 = Ellipse(xy = (0.0, 0.0), width = 4, height = 8, angle = 30.0, facecolor= 'yellow', alpha=0.3)
cir1 = Circle(xy = (0.0, 0.0), radius=2, alpha=0.5)
ax.add_patch(ell1)
ax.add_patch(cir1)
x, y = 0, 0
ax.plot(x, y, 'ro')
plt.axis('scaled')
plt.axis('equal') #changes limits of x or y axis so that equal increments of x and y have the same length
plt.show()
import numpy as np
import matplotlib.pyplot as plt
x = y = np.arange(-4, 4, 0.1)
x, y = np.meshgrid(x,y)
plt.contour(x, y, x**2 + y**2, [9]) #x**2 + y**2 = 9 的圆形
plt.axis('scaled')
plt.show()