-
Notifications
You must be signed in to change notification settings - Fork 0
/
Microsoft.py
53 lines (31 loc) · 1.7 KB
/
Microsoft.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
'''Microsoft Cloud Society Project'''
'''Project details: A python program that takes input of years and population from user and shows a graph showing its regression line with its projection.
It also generates 10 random numbers for both x and y axis.'''
#import seaborn as sns; sns.set()
import numpy as np
import matplotlib.pyplot as plt
#Below is the code for entering your own data if you do not want to import data. You only need to remove quotations.
''' m=yearsBase=list(input("Enter value(s) of x axis i.e Years:"))
t=meanBase=list(input("Enter value(s) of y axis i.e Mean Temperature:")) '''
import pandas as pd
'''Using Panda'''
yearsBase, meanBase = np.loadtxt(r"C:\Users\VICTOR\Documents\Programming (Python)\\5-year-mean-1951-1980.csv", delimiter=',', usecols=(0, 1),unpack=True)
years, mean = np.loadtxt(r"C:\Users\VICTOR\Documents\Programming (Python)\\5-year-mean-1882-2014.csv", delimiter=',', usecols=(0, 1),unpack=True)
#Below is the code that generates random numbers for axes(m and d). You only need to remove quotations.
''' meanBase=np.round(np.random.normal(1.74,0.20,10),10)
yearBase=np.round(np.random.normal(1.84,0.80,10),10) '''
m,t =(yearsBase, meanBase)
def f(x):
return m*x + t
plt.xlabel('Mean Temperature', fontsize=10)
plt.ylabel('Years',fontsize=10)
plt.title('Mean Temperature versus Years.',fontsize=15)
plt.grid()
plt.yticks(color='blue')
plt.xticks(color='red')
plt.scatter(yearsBase,meanBase,edgecolors='black')
plt.plot(yearsBase,meanBase)
plt.show()
print('y={0}*x + {1}'.format(m,t)) #To display slope and intercept on the graph.
#sns.regplot(yearsBase, meanBase) #To show projection of line.
plt.show()