博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
情人节——爱心代码
阅读量:4478 次
发布时间:2019-06-08

本文共 2301 字,大约阅读时间需要 7 分钟。

import numpy
as np
import matplotlib.pyplot
as plt
x_coords = np.linspace(-
100,
100,
500)
y_coords = np.linspace(-
100,
100,
500)
points = []
for y
in y_coords:
for x
in x_coords:
if ((x*
0.03)**
2+(y*
0.03)**
2-
1)**
3-(x*
0.03)**
2*(y*
0.03)**
3 <=
0:
# 引用公式
points.append({
"x": x,
"y": y})
heart_x = list(map(
lambda point: point[
"x"], points))
heart_y = list(map(
lambda point: point[
"y"], points))
plt.scatter(heart_x, heart_y, s=
10, alpha=
0.5,c=range(len(heart_x)), cmap=
'cool')
plt.show()
#颜色
#autumn/spring/rainbow/cool/magma/Reds/viridis/gist_rainbow/

 

#values: Accent, Accent_r, Blues, Blues_r, BrBG, BrBG_r, BuGn, BuGn_r, BuPu,
#BuPu_r, CMRmap, CMRmap_r, Dark2, Dark2_r, GnBu, GnBu_r, Greens, Greens_r, Greys, Greys_r, OrRd, OrRd_r, Oranges, Oranges_r, PRGn, PRGn_r,
#Paired, Paired_r, Pastel1, Pastel1_r, Pastel2, Pastel2_r, PiYG, PiYG_r, PuBu, PuBuGn, PuBuGn_r, PuBu_r, PuOr, PuOr_r, PuRd, PuRd_r,
#Purples, Purples_r, RdBu, RdBu_r, RdGy, RdGy_r, RdPu, RdPu_r, RdYlBu, RdYlBu_r, RdYlGn, RdYlGn_r, Reds, Reds_r,Set1, Set1_r, Set2, Set2_r,
#Set3, Set3_r, Spectral, Spectral_r, Vega10, Vega10_r, Vega20, Vega20_r, Vega20b, Vega20b_r, Vega20c, Vega20c_r, Wistia, Wistia_r, YlGn,
#YlGnBu, YlGnBu_r, YlGn_r, YlOrBr, YlOrBr_r, YlOrRd, YlOrRd_r, afmhot, afmhot_r, autumn, autumn_r, binary, binary_r, bone, bone_r, brg,
#brg_r, bwr, bwr_r, cool, cool_r, coolwarm, coolwarm_r, copper, copper_r, cubehelix, cubehelix_r, flag, flag_r, gist_earth, gist_earth_r,
#gist_gray, gist_gray_r, gist_heat, gist_heat_r, gist_ncar, gist_ncar_r, gist_rainbow, gist_rainbow_r, gist_stern, gist_stern_r, gist_yarg,
#gist_yarg_r, gnuplot, gnuplot2, gnuplot2_r, gnuplot_r, gray, gray_r, hot, hot_r, hsv, hsv_r, inferno, inferno_r, jet, jet_r, magma,
# magma_r, nipy_spectral, nipy_spectral_r, ocean, ocean_r, pink, pink_r, plasma, plasma_r, prism, prism_r, rainbow, rainbow_r, seismic,
# seismic_r, spectral, spectral_r, spring, spring_r, summer, summer_r, tab10, tab10_r, tab20, tab20_r, tab20b, tab20b_r, tab20c, tab20c_r,
# terrain, terrain_r, viridis, viridis_r, winter, winter_r

情人节送给 情人一个爱心如何 试试吧 很有效的

首先下载 

pip install numpy

 

pip install matplotlib

 

在标紫的地方可以自定义颜色 上面有喜欢颜色的代码

plt.scatter(heart_x, heart_y, s=10, alpha=0.5,c=range(len(heart_x)), cmap='cool')

 

转载于:https://www.cnblogs.com/bo686/p/10374909.html

你可能感兴趣的文章
多线程09-Mutex
查看>>
Ionic4.x 中的 UI 组件(UI Components) Slides 轮播图组件、Searchbar 组件、 Segment 组件
查看>>
ssh框架整合完整版
查看>>
Yii2——在模型(Model)中使用分页(Pagination)
查看>>
ServletConfig接口
查看>>
初识nginx\squid\nfs\tomcat
查看>>
P4752 Divided Prime
查看>>
[C#]C#学习笔记-CIL和动态程序集
查看>>
[Effective C# 4.0 译] 条款21:限定类型的可见性
查看>>
离散化
查看>>
leetcode 23. Merge k Sorted Lists(堆||分治法)
查看>>
用C++建立一个窗口
查看>>
第二百八十八天 how can I坚持
查看>>
在mac上安装ruby
查看>>
javascript 开发规范
查看>>
同一服务器上安装多个tomcat
查看>>
提交JSON修改数据
查看>>
用户体验评价
查看>>
HDU 3432
查看>>
Android 编程下将 Bitmap 转为 InputStream
查看>>