mirror of
https://github.com/WMK965/965-Python-Learning-Repo.git
synced 2025-04-27 20:13:21 +00:00
更新示例代码
This commit is contained in:
parent
0cf8f56a68
commit
f6b921e0d6
59
Calculate.py
59
Calculate.py
@ -86,4 +86,63 @@ for i in range(0, 5):
|
|||||||
|
|
||||||
print(\'''BMI数值为:{0}
|
print(\'''BMI数值为:{0}
|
||||||
BMI指标为:国际'{1}',国内'{2}\'\'''.format(round(inp, 2), outg, outcn))
|
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()
|
||||||
'''
|
'''
|
@ -60,3 +60,22 @@ arr3= {arr3.flatten()}
|
|||||||
arr4= {arr4}
|
arr4= {arr4}
|
||||||
arr5= {arr5}\''')
|
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()
|
||||||
|
'''
|
||||||
|
14
ex3.csv
Executable file
14
ex3.csv
Executable file
@ -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
|
|
16
temp.py
Normal file → Executable file
16
temp.py
Normal file → Executable file
@ -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}''')
|
|
Loading…
Reference in New Issue
Block a user