作为一名程序猿,每每在女盆友说你不爱我了的时候,总是显得那么的词穷,好像读了这么多年的书都喂了狗一样。
但是今天,我要用代码宣言,要让世界看见我的表白。
代码运行需要numpy、matplotlib,安装很简单,就不侮辱大家的智商了。
Jack还缺一次对Rose的表白:
import matplotlib.pyplot as plt
from matplotlib import animation
import numpy as np
import math
t = np.linspace(0, math.pi, 1000)
x = np.sin(t)
y = np.cos(t) + np.power(x, 2.0/3)
fig, ax = plt.subplots()
ax.fill_between(x, 0, y, color='pink', label='Rose')
ax.fill_between(-x, 0, y, color='pink')
ax.fill_between(x+0.4, 0, y+0.4, color='red', label='Jack')
ax.fill_between(-x+0.4, 0, y+0.4, color='red')
plt.axis([-2, 2, -2, 2])
plt.xticks([])
plt.yticks([])
plt.legend(loc='lower right', fancybox=True, framealpha=0.5, shadow=True, borderpad=1.5)
plt.xkcd()
plt.show()
效果图: