Wednesday, February 26, 2014

Data virtualization

Requirement to complete is  matplotlib

1- axis = 20
2- random number from 1-100 for 20 times

--- script source --
#!/usr/bin/python
import matplotlib.pyplot as plt
import random
radius = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]

#x is axis and d is data, both are list
x = range(20)
d = []
for i in range(20):
 k = random.randint(1.0,100.0)
 d.append(k)

area = [3.14159, 12.56636, 28.27431, 50.26544, 78.53975, 113.09724]
#plt.plot(radius, area)
plt.plot(x, d)
plt.xlabel('Radius')
plt.ylabel('Area')
plt.title('Area of a Circle')
plt.show()




No comments:

Post a Comment