# 这三行代码使编译器能够绘图:
import sys
import matplotlib
matplotlib.use('Agg')
import numpy as np
import matplotlib.pyplot as plt
# 准备运动数据(心率和卡路里):
x = np.array([80, 85, 90, 95, 100, 105, 110, 115, 120, 125])
y = np.array([240, 250, 260, 270, 280, 290, 300, 310, 320, 330])
plt.title("运动监测数据")
plt.xlabel("平均心率")
plt.ylabel("卡路里消耗")
plt.plot(x, y) # 绘制折线图
plt.grid(axis = 'y') # 仅显示 y 轴方向的网格线
plt.show()
# 这两行代码使编译器能够输出图形:
plt.savefig(sys.stdout.buffer)
sys.stdout.flush()