1+ import matplotlib .pyplot as plt
2+ import seaborn
3+ import numpy
4+
5+ # 定义方法
6+ def draw_love ():
7+ #拼凑字母
8+ l = numpy .arange (0 , 4 , 0.01 )
9+ L = 1.0 / l
10+ theta = numpy .arange (- 4 , 4 , 0.01 )
11+ o = 3.0 * numpy .cos (theta )
12+ O = 3.0 * numpy .sin (theta )
13+ v = numpy .arange (- 4 , 4 , 0.01 )
14+ V = numpy .abs (- 2.0 * v )
15+ e = numpy .arange (- 3 , 3 , 0.01 )
16+ E = - 1.0 * numpy .abs (numpy .sin (e ))
17+ y = numpy .arange (- 10 , 10 , 0.01 )
18+ Y = numpy .log2 (numpy .abs (y ))
19+ u = numpy .arange (- 4 , 4 , 0.01 )
20+ U = 2.0 * u ** 2
21+ points = []
22+
23+ for heartY in numpy .linspace (- 100 , 100 , 500 ):
24+ for heartX in numpy .linspace (- 100 , 100 , 500 ):
25+ if ((heartX * 0.03 ) ** 2 + (heartY * 0.03 ) ** 2 - 1 ) ** 3 - (heartX * 0.03 ) ** 2 * (
26+ heartY * 0.03 ) ** 3 <= 0 :
27+ points .append ({"x" : heartX , "y" : heartY })
28+ # 设置直角坐标系
29+ heart_x = list (map (lambda point : point ["x" ], points ))
30+ heart_y = list (map (lambda point : point ["y" ], points ))
31+
32+ # 添加网格
33+ fig = plt .figure (figsize = (13 , 7 ))
34+ ax_L = fig .add_subplot (2 , 4 , 1 )
35+ ax_O = fig .add_subplot (2 , 4 , 2 )
36+ ax_V = fig .add_subplot (2 , 4 , 3 )
37+ ax_E = fig .add_subplot (2 , 4 , 4 )
38+ ax_Y = fig .add_subplot (2 , 4 , 5 )
39+ ax_O_2 = fig .add_subplot (2 , 4 , 6 )
40+ ax_U = fig .add_subplot (2 , 4 , 7 )
41+ ax_heart = fig .add_subplot (2 , 4 , 8 )
42+
43+ # 设置坐标
44+ ax_L .plot (l , L )
45+ ax_O .plot (o , O )
46+ ax_V .plot (v , V )
47+ ax_E .plot (E , e )
48+ ax_Y .plot (y , Y )
49+ ax_Y .axis ([- 10.0 , 10.0 , - 10.0 , 5.0 ])
50+ ax_O_2 .plot (o , O )
51+
52+ ax_U .plot (u , U )
53+
54+ ax_heart .scatter (heart_x , heart_y , s = 10 , alpha = 0.5 )
55+ # 设置颜色
56+ plt .plot (color = 'red' )
57+ # 展示结果
58+ plt .show ()
59+
60+ # 主函数
61+ if __name__ == '__main__' :
62+ seaborn .set_style ('dark' )
63+ draw_love ()
0 commit comments