fork download
  1. # your code goes here
Success #stdin #stdout 0.09s 14200KB
stdin
import numpy as np
import matplotlib.pyplot as plt

# 设置画布
fig, ax = plt.subplots(figsize=(6, 6))
ax.set_aspect('equal')

# 生成爱心形状的数据
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)

# 绘制爱心
ax.fill(x, y, 'red', alpha=0.8)

# 设置标题和坐标轴
ax.set_title('Python爱心', fontsize=15)
ax.set_xlim(-20, 20)
ax.set_ylim(-20, 15)
ax.axis('off')  # 隐藏坐标轴

# 显示图形
plt.show()
stdout
Standard output is empty