更新示例代码

This commit is contained in:
965 2023-05-23 20:56:35 +08:00
parent 2dcd1cb34e
commit 7bd9402243
3 changed files with 92 additions and 14 deletions

View File

@ -111,6 +111,65 @@ import numpy as np
import matplotlib.pyplot as plt
def draw(a):
t = np.linspace(0, 2 * np.pi, 1025)
y = a * (2 * np.cos(t) - np.cos(2 * t))
x = a * (2 * np.sin(t) - np.sin(2 * t))
plt.xlim(-6, 6)
plt.ylim(-7, 4)
plt.plot(x, y, linewidth=1, color='red')
plt.fill_between(x, y, facecolor='yellow', alpha=0.5)
plt.figure(num=1, figsize=(24, 6))
plt.subplot(1, 3, 1)
draw(0.5)
plt.subplot(1, 3, 2)
draw(1)
plt.subplot(1, 3, 3)
draw(2)
plt.show()
plt.savefig('heart.jpg')
'''
'''
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
A1 = np.loadtxt('ex3.csv', dtype=str, delimiter=',')
X = np.array(A1[13][1:])
Y = np.array(A1[0][1:])
plt.pie(X, labels=Y, autopct='%1.1f%%')
plt.title('各科室总就诊人数')
plt.savefig('饼图.png')
plt.show()
'''
'''
import numpy as np
import matplotlib.pyplot as plt
data = np.arange(0, 1, 0.001)
plt.title("lines")
plt.xlabel('x')
plt.ylabel('y')
plt.xlim((0, 1))
plt.ylim((0, 1))
b = np.arange(0, 1, 0.2)
plt.xticks(b)
plt.yticks([0, 0.5, 1])
plt.plot(data, np.power(data, 2), linewidth=3, color='blue', linestyle='--')
plt.plot(data, np.power(data, 3), linewidth=1, color='green')
plt.legend(['y=x^2', 'y=x^3'])
plt.savefig("jg.png")
plt.show()
'''
'''
import numpy as np
import matplotlib.pyplot as plt
def draw(a):
t = np.linspace(0, 2 * np.pi, 1025)
y = a * (2 * np.cos(t) - np.cos(2 * t))

View File

@ -79,3 +79,22 @@ plt.plot(month, n2_data, marker='o', color='blue', linestyle='--', label='内二
plt.legend(['内一科', '内二科'])
plt.show()
'''
'''
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
A1 = np.loadtxt('ex3.csv', dtype=str, delimiter=',')
month = np.array(A1[:, 0][1:13])
n1_data = [eval(x) for x in A1[:, 1][1:13]]
n2_data = [eval(x) for x in A1[:, 2][1:13]]
plt.title('内一科和内二科全年门诊量比较')
plt.xlabel('月份')
plt.ylabel('就诊人数')
plt.plot(month, n1_data, marker='*', color='red', linestyle='-', label='内一科')
plt.plot(month, n2_data, marker='o', color='blue', linestyle='--', label='内二科')
plt.legend(['内一科', '内二科'])
plt.show()
'''

28
ex3.csv
View File

@ -1,14 +1,14 @@
月份,内一科,内二科,外一科,外二科,妇产科,儿科,耳鼻喉科,皮肤科,中医科,口腔科
一月,1239,803,672,1079,945,523,320,3292,404,978
二月,1034,789,693,845,864,451,240,181,270,910
三月,1152,975,819,894,944,655,291,182,429,1097
四月,803,842,708,684,759,681,395,129,242,935
五月,970,693,682,650,754,508,161,331,208,1105
六月,912,872,746,681,798,411,159,414,227,937
七月,921,866,771,618,872,439,200,428,338,1014
八月,902,829,735,663,801,485,179,439,252,992
九月,735,957,768,789,871,439,162,418,226,1130
十月,936,808,692,864,803,599,234,132,198,994
十一月,1099,1058,784,964,1031,535,315,203,315,1050
十二月,1005,565,728,986,962,486,275,208,329,1109
总计,11708,10057,8798,9717,10404,6212,2931,6357,3438,12251
月份,内一科,内二科,外一科,外二科,妇产科,儿科,耳鼻喉科,皮肤科,中医科,口腔科
一月,1239,803,672,1079,945,523,320,3292,404,978
二月,1034,789,693,845,864,451,240,181,270,910
三月,1152,975,819,894,944,655,291,182,429,1097
四月,803,842,708,684,759,681,395,129,242,935
五月,970,693,682,650,754,508,161,331,208,1105
六月,912,872,746,681,798,411,159,414,227,937
七月,921,866,771,618,872,439,200,428,338,1014
八月,902,829,735,663,801,485,179,439,252,992
九月,735,957,768,789,871,439,162,418,226,1130
十月,936,808,692,864,803,599,234,132,198,994
十一月,1099,1058,784,964,1031,535,315,203,315,1050
十二月,1005,565,728,986,962,486,275,208,329,1109
总计,11708,10057,8798,9717,10404,6212,2931,6357,3438,12251

1 月份 内一科 内二科 外一科 外二科 妇产科 儿科 耳鼻喉科 皮肤科 中医科 口腔科
2 一月 1239 803 672 1079 945 523 320 3292 404 978
3 二月 1034 789 693 845 864 451 240 181 270 910
4 三月 1152 975 819 894 944 655 291 182 429 1097
5 四月 803 842 708 684 759 681 395 129 242 935
6 五月 970 693 682 650 754 508 161 331 208 1105
7 六月 912 872 746 681 798 411 159 414 227 937
8 七月 921 866 771 618 872 439 200 428 338 1014
9 八月 902 829 735 663 801 485 179 439 252 992
10 九月 735 957 768 789 871 439 162 418 226 1130
11 十月 936 808 692 864 803 599 234 132 198 994
12 十一月 1099 1058 784 964 1031 535 315 203 315 1050
13 十二月 1005 565 728 986 962 486 275 208 329 1109
14 总计 11708 10057 8798 9717 10404 6212 2931 6357 3438 12251