forked from tanishh/HH-PA2609
-
Notifications
You must be signed in to change notification settings - Fork 0
/
22Plot2.py
154 lines (93 loc) · 2.83 KB
/
22Plot2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#Box Plot
import matplotlib.pyplot as plt
SMALL_SIZE = 12
MEDIUM_SIZE = 14
BIGGER_SIZE = 16
plt.rc('font', size=SMALL_SIZE) # controls default text sizes
plt.rc('axes', titlesize=SMALL_SIZE) # fontsize of the axes title
plt.rc('axes', labelsize=MEDIUM_SIZE) # fontsize of the x and y labels
plt.rc('xtick', labelsize=SMALL_SIZE) # fontsize of the tick labels
plt.rc('ytick', labelsize=SMALL_SIZE) # fontsize of the tick labels
plt.rc('legend', fontsize=SMALL_SIZE) # legend fontsize
plt.rc('figure', titlesize=BIGGER_SIZE) # fontsize of the figure title
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
data_1 = np.random.normal(100, 10, 200)
plt.hist(data_1)
data_1.min()
data_1.max()
data_1.mean()
data_1.std()
data_2 = np.random.normal(90, 20, 200)
data_2.mean()
data_3 = np.random.normal(80, 30, 200)
data_3.mean()
data_4 = np.random.normal(70, 40, 200)
data_4.mean()
data_5 = np.random.randint(50, 100, 10)
data_5.mean()
data_7 = np.random.normal(70, 10, 11)
data_7.mean()
data_7.sort()
data_7
data_6 = np.array([1,2,3,8,9])
data_6.mean()
data_6.sort()
data_6
data = [data_1, data_2, data_3, data_4, ]
fig = plt.figure(figsize =(5, 5), dpi=300, facecolor='r')
ax = fig.add_axes([1,2,3,4])
ax.boxplot(data)
#ax.set_xticklabels(fontsize=14)
ax.tick_params(axis='y', labelsize=30)
# show plot
plt.show()
'''
The given code includes a list of heights for various basketball players.
You need to calculate and output how many players are in the range of
one standard deviation from the mean this is the actual question
the range of one standard deviation from the mean?
'''
x1 = [180, 172, 178, 185, 190, 195, 192, 200, 210, 190]
fig = plt.figure(figsize =(5, 5), dpi=300, facecolor='r')
ax = fig.add_axes([1,2,3,4])
bp = ax.boxplot(x1)
np.mean(x1)
np.median(x1)
np.std(x1)
np.min(x1)
np.max(x1)
mx= np.mean(x1) + np.std(x1)
mi = np.mean(x1) - np.std(x1)
cnt=0
for i in x1:
if (i>mi and i<mx):
cnt=cnt+1
cnt
import seaborn as sns
sns.set_theme(style="whitegrid")
tips = sns.load_dataset("tips")
tips.columns
ax = sns.boxplot(x=tips["total_bill"])
ax = sns.boxplot(x=tips["tip"])
sns.scatterplot(tips["total_bill"], tips["tip"])
l1 = [1,4,7,9,10]
np.mean(l1)
#Different dataset
import pandas as pd
data = pd.read_csv('brain_size.csv', sep=';', na_values='.')
data.head()
# Box plot of FSIQ and PIQ (different measures od IQ)
plt.figure(figsize=(4, 3), dpi=300, facecolor= 'Yellow', edgecolor='Red')
data.columns
data.boxplot(['FSIQ', 'PIQ', 'VIQ'])
plt.show();
data
data['FSIQ'] - data['PIQ']
# Boxplot of the difference
plt.figure(figsize=(4, 3))
plt.boxplot(data['FSIQ'] - data['PIQ'])
plt.xticks((0, 1, 2), ('VV', 'FSIQ - PIQ', 'AA' ))
plt.yticks((-10, -15,), ("BB", "AA",))
plt.show();