# 以下三行代码使编译器支持绘图功能:
import sys
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
# 准备饼图数据:
y = np.array([35, 25, 25, 15]) # 各区块数值
mylabels = ["苹果", "香蕉", "樱桃", "枣子"] # 区块标签
# 绘制基础饼图:
plt.pie(y, labels = mylabels) # 创建带标签的饼图
plt.show() # 显示图表
# 以下两行代码使编译器能够输出图形:
plt.savefig(sys.stdout.buffer)
sys.stdout.flush()