import matplotlib.pyplot as plt import numpy as np # -pi ~ pi, split 256 t = np.linspace(-np.pi, np.pi, 256, endpoint=True) X = 16 * (np.sin(t))**3 Y = 13 * np.cos(t) - 5 * np.cos(2 * t) - 2 * np.cos(3 * t) - np.cos(4 * t) # plot at line1 column1 plt.subplot(121) plt.plot(X, Y) # -3 ~ 3, step 0.02 x = y = np.arange(-3.0, 3.0, 0.02) X, Y = np.meshgrid(x, y) Z = (X**2 + Y**2 - 1)**3 - X**2 * Y**3 # plot at line1 column2 plt.subplot(122) plt.contour(X, Y, Z) plt.colorbar() plt.show()
得到如图所示即为成功!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)