Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # this program prints out ten different lines on a graph based
- # on a random number. The random number will be the y axis value
- # import the python libraries for plotting
- import matplotlib.pyplot as plt
- import numpy as np
- # set x axis value to 50 to prevent the legend from covering up the first line
- a = 50
- # create the list to store the legend values
- list = []
- # loop through 10 times to create 10 separate lines on the graph
- # with random values between 30 and 300
- for b in range(0, 10):
- x = np.random.random_integers(30, 300)
- y = np.arange(x)
- list.append(x)
- plt.plot(y + a, y)
- a = a + 50
- # plot the legend on the graph in the upper left hand corner
- plt.legend(list, loc = 'upper left')
- # display the multi-line graph
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment