Guest User

Untitled

a guest
Dec 13th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. x = np.linspace(-10, 10)
  4. y = np.cos(x) / 2. + .5
  5. z = np.sin(x) / 20. + .5
  6.  
  7.  
  8. def jr_transform(x, baseline=.50, scaling=100):
  9. x = x - baseline
  10. above = np.log(scaling*x*(x>0)+1)
  11. below = np.log(-scaling*x*(x<=0)+1)
  12. x = np.nan_to_num(above) - np.nan_to_num(below)
  13. return x / 2. + baseline
  14.  
  15. fig, (ax, ax1) = plt.subplots(1, 2)
  16. ax.plot(x, y, color='C0')
  17. ax.plot(x, z, color='C1')
  18. yticks = np.linspace(0, 1, 11)
  19. ax.set_yticks(yticks)
  20. ax.set_yticklabels(['.%.2f' % i for i in yticks])
  21.  
  22. ax.set_title('original')
  23.  
  24. ax1.plot(x, jr_transform(y), color='C0')
  25. ax1.plot(x, jr_transform(z), color='C1')
  26. ax1.set_yticks(jr_transform(yticks))
  27. ax1.set_yticklabels(['.%.2f' % i for i in yticks])
  28. ax1.set_title('log')
  29. plt.show()
Add Comment
Please, Sign In to add comment