python绘制心形的方法:利用matplotlib和numpy画心形,代码为【init = np.arange(-np.pi, np.pi, 0.001);plt.fill_between(x, y, facecolor='red')】。
相关学习推荐:python教程
python绘制心形的方法:
python 利用 matplotlib 和 numpy 画心形。
import matplotlib.pyplot as plt import numpy as np #初始化数据 init = np.arange(-np.pi, np.pi, 0.001) y = np.subtract(np.multiply(2, np.cos(init)), np.cos(np.multiply(2, init))) x = np.subtract(np.multiply(2, np.sin(init)), np.sin(np.multiply(2, init))) #画图 plt.plot(x, y) plt.fill_between(x, y, facecolor='red') plt.show()
结果:
Copyright © 2019- tachun.com.cn 版权所有
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务