天天看点

用python3表白_情人节&七夕,来一次Python3式的表白

# 爱心线的方程的表达为:x** 2+ y** 2 + a * x= a * sqrt(x** 2+y** 2) 和 x** 2+ y** 2 - a * x= a * sqrt(x** 2+y** 2)

# 软件设计的“万能层”:x=a*(2*cos(t)-cos(2*t)) y=a*(2*sin(t)-sin(2*t))

import numpy as np

import matplotlib.pyplot as plt

'''

#x,y两个表达式

a = 1

t = np.linspace(0, 2 * np.pi, 1024)

x = a * (2 * np.cos(t) - np.cos(2 * t))

y = a * (2 * np.sin(t) - np.sin(2 * t))

plt.plot(y, x, color='r')

plt.show() '''

# 极坐标r=a(1-sinθ)

a = 1

T = np.linspace(0, 2 * np.pi, 1024)

plt.axes(polar=True)

# for a in range(1, 5):

#    plt.plot(T, a*(1.-np.sin(T)), color='r')

plt.plot(T, a*(1.-np.sin(T)), color='r')

plt.axis('off')  # 去掉坐标轴

plt.show()

'''

# 受伤的心 y=a*|x|-b*sqrt(64-x^2) a越小越胖,b越大上下越胖

x = np.linspace(-8, 8, 1024)

y1 = 0.6 * np.abs(x) - 0.8 * np.sqrt(64 - x ** 2)

y2 = 0.6 * np.abs(x) + 0.8 * np.sqrt(64 - x ** 2)

plt.plot(x, y1, color='r', alpha=0)

plt.plot(x, y2, color='r', alpha=0)

# facecolr填充的颜色,alpha透明度,label标签

plt.fill(x, y1, facecolor='r', alpha=0.5, label='y1')

plt.fill(x, y2, facecolor='r', alpha=0.5, label='y2')

plt.axis('off')  # 去掉坐标轴

# plt.xticks([])  # 去掉x轴刻度

# plt.yticks([])  # 去掉Y轴刻度

plt.show()'''