diff --git a/README.md b/README.md index 9cb3ef4..0b38cb4 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,46 @@ def work(x): plt.grid(linestyle=':',alpha=0.3) plt.savefig('project/step7/image/user.png') +3. +import matplotlib +import matplotlib.pyplot as plt +import numpy as np +plt.rcParams['font.sans-serif']=['SimHei'] +def work(x,y): + # ********** Begin *********# + n = ['语文','数学','英语','物理','化学','历史','政治','体育','美术','音乐'] + z = np.arange(len(n)) + plt.figure(figsize=(10, 10)) + width = 0.4 + fig,ax = plt.subplots(figsize=(10, 10)) + rect1 = ax.bar(z-width/2,x,color = '#3170a7',width=width,label='小明') + rect2 = ax.bar(z+width/2,y,color = 'pink',width=width,label='小花') + ax.set_ylabel('分数') + ax.set_title('小明与小花期末考试的各科成绩') + ax.set_xticks(z) + ax.set_xticklabels(n) + ax.legend() + plt.legend(loc='upper left') + plt.savefig('project/step3/image/user.png') + plt.close() + # ********** End **********# + 6. +import matplotlib +import matplotlib.pyplot as plt +plt.rcParams['font.sans-serif']=['SimHei'] +def work(x): + # ********** Begin *********# + plt.figure(figsize=(10,10)) + labels = ['语文','数学','英语','物理','化学','历史','政治','体育','美术','音乐'] + plt.title('小明的期末成绩各科占比') + max_val = max(x) + explode = [0.1 if val == max_val else 0 for val in x] + plt.pie(x,labels=labels,autopct='%.2f%%',explode=explode) + plt.savefig('project/step6/image/user.png') + + + # ********** End **********# # ********** End **********# \ No newline at end of file