python画图代码彩虹-⽤python画⼀颗彩虹⾊爱⼼送给⼥朋
eclipse jee
1.准备⼯作:
代码中⽤到numpy和matplotlib,需要先安装这两个库
pip3 install numpypip3 install matplotlib
会⽤到的数学公式:(x^2+y^2-1)^3+x^2*y^3=0
2.编写代码:
importnumpy asnp微网站设计费用
importmatplotlib.pyplot asplt
x_coords = np.linspace(- 100, 100, 500)
python代码画图案
易语言编程入门教程appy_coords = np.linspace(- 100, 100, 500)
points = []
fory iny_coords:
雪崩百度百科forx inx_coords:
if((x* 0.03)** 2+(y* 0.03)** 2- 1)** 3-(x* 0.03)** 2*(y* 0.03)** 3<= 0:亲爱的热爱的grunt结局
points.append({ "x": x, "y": y})
heart_x = list(map( lambdapoint: point[ "x"], points))
heart_y = list(map( lambdapoint: point[ "y"], points))
plt.scatter(heart_x, heart_y, s= 10, alpha= 0.5,c=range(len(heart_x)), cmap=)
plt.show()
运⾏后上⾯的代码会显⽰下⾯的图
这样我们的彩虹⾊爱⼼就出来了。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。