Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3.  
  4.  
  5. def f(x, s):
  6.     return 1. / (1. + float(abs(x - 2.)) / abs(s))
  7.  
  8. f = np.vectorize(f)
  9.  
  10. x = np.linspace(-8, 10, 1000, endpoint=True)
  11.  
  12. plt.plot(x, f(x, 0.25), label='s=0.25')
  13. plt.plot(x, f(x, 1.00), label='s=1.00')
  14. plt.plot(x, f(x, 4.00), label='s=4.00')
  15. plt.legend(loc='best')
  16. plt.show()
  17.  
  18.  
  19. x = []
  20. y = []
  21. c = []
  22.  
  23. with open('input.txt') as f:
  24.     for line in f:
  25.         x.append(float(line.split('\t')[0]))
  26.         y.append(float(line.split('\t')[1]))
  27.         if line.split('\t')[2] == '1':
  28.             c.append(1)
  29.         elif line.split('\t')[3] == '1':
  30.             c.append(2)
  31.         else:
  32.             c.append(3)
  33.        
  34.  
  35. plt.scatter(x, y, c = c)
  36. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement