brewersfan1976

ch7-ex3.py

Aug 18th, 2015
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. # this program prints out an area graph
  2. # based on 10 different random values
  3.  
  4. # import the python libraries for plotting
  5.  
  6. import matplotlib.pyplot as plt
  7. import numpy as np
  8.  
  9. # create the list to store the legend values
  10.  
  11. list = []
  12.  
  13. # loop through 10 times to create 10 separate lines on the graph
  14. # with random values between 30 and 300
  15.  
  16. for b in range(0, 10):
  17.     x = np.arange(10)
  18.     y = np.random.random_integers(30, 300)
  19.     list.append(y)
  20.    
  21. plt.plot(list)
  22.  
  23. # fill in the area
  24.  
  25. plt.fill_between(x, list)
  26.  
  27. print list
  28.  
  29. # display the area graph
  30.  
  31. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment