python笛卡尔爱心代码
时间: 2023-12-05 22:41:20 浏览: 70
Python爱心代码爱心代码
以下是Python实现笛卡尔爱心的代码:
```python
import matplotlib.pyplot as plt
import numpy as np
t = np.linspace(0, 2*np.pi, 1000)
x = 16 * np.sin(t)**3
y = 13 * np.cos(t) - 5 * np.cos(2*t) - 2 * np.cos(3*t) - np.cos(4*t)
plt.plot(x, y, color='red', linewidth=2)
plt.axis('equal')
plt.title('Cartesian Heart')
plt.show()
```
阅读全文