avatar
Untitled

Guest 15 6th Nov, 2019

MARKUP 0.85 KB
                                           
                         import numpy as np
import matplotlib.pyplot as plt

file = input("Enter file name: ")
fileopen = open(file).read().splitlines()
cleanfile = [ x.split(',') for x in fileopen if x != '' ]

w = []
h = []
bmi = []

for i in range(len(cleanfile)):
    x = float(cleanfile[i][0])
    y = float(cleanfile[i][1])
    w.append(x)
    h.append(y)
hm = [x/100 for x in h]
for i in range(len(cleanfile)):
    z = w[i]/(hm[i]**2)
    bmi.append(z)

hi = np.array(h)
wa = np.array(w)
rainfall = np.array(bmi)

plt.scatter(wa,hi,c=rainfall)
plt.xlabel("Weight (kg)")
plt.ylabel("Height (cm)")
plt.grid(True)
bar = plt.colorbar()  # add a color bar
bar.ax.set_title("BMI")  # add title to the color bar
plt.set_cmap("jet")  # set color mapping scheme to "jet"
plt.show()
                      
                                       
To share this paste please copy this url and send to your friends
RAW Paste Data