From f6b921e0d625981e4abffb59f9da6ad4da9ac38a Mon Sep 17 00:00:00 2001 From: 965 Date: Wed, 17 May 2023 10:08:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=A4=BA=E4=BE=8B=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Calculate.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ datatype_info.py | 19 ++++++++++++++++ ex3.csv | 14 ++++++++++++ temp.py | 16 ------------- 4 files changed, 92 insertions(+), 16 deletions(-) create mode 100755 ex3.csv mode change 100644 => 100755 temp.py diff --git a/Calculate.py b/Calculate.py index d4652b4..6054d60 100755 --- a/Calculate.py +++ b/Calculate.py @@ -86,4 +86,63 @@ for i in range(0, 5): print(\'''BMI数值为:{0} BMI指标为:国际'{1}',国内'{2}\'\'''.format(round(inp, 2), outg, outcn)) +''' +''' +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)) + 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() ''' \ No newline at end of file diff --git a/datatype_info.py b/datatype_info.py index 4f647c3..7a63793 100755 --- a/datatype_info.py +++ b/datatype_info.py @@ -60,3 +60,22 @@ arr3= {arr3.flatten()} arr4= {arr4} arr5= {arr5}\''') ''' +''' +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() +''' diff --git a/ex3.csv b/ex3.csv new file mode 100755 index 0000000..bbd25b9 --- /dev/null +++ b/ex3.csv @@ -0,0 +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 diff --git a/temp.py b/temp.py old mode 100644 new mode 100755 index 38e6f43..8b13789 --- a/temp.py +++ b/temp.py @@ -1,17 +1 @@ -import numpy as np -L = [[2.73351472, 0.47539713, 3.63280356, 1.4787706, 3.13661701], - [1.40305914, 2.27134829, 2.73437132, 1.88939679, 0.0384238], - [1.56666697, -0.40088431, 0.54893762, 3.3776724, 2.27490386]] -arr = np.array(L) -arr1 = np.array((arr[0][1], arr[1][1], arr[2][1])) -arr1 = arr1.reshape(3, 1) -arr2 = np.array((arr[1][2:5], arr[2][2:5])) -arr3 = np.array((arr[0][1:5:2], arr[2][1:5:2])).flatten() -arr4 = arr[np.where(np.logical_and(arr >= 2.5, arr <= 3.5))] -arr5 = arr[np.where(np.logical_or(arr >= 3, arr <= 0))] -print(f'''arr1= {arr1} -arr2= {arr2} -arr3= {arr3.flatten()} -arr4= {arr4} -arr5= {arr5}''') \ No newline at end of file