Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- import numpy as np
- x = np.linspace(-10, 10)
- y = np.cos(x) / 2. + .5
- z = np.sin(x) / 20. + .5
- def jr_transform(x, baseline=.50, scaling=100):
- x = x - baseline
- above = np.log(scaling*x*(x>0)+1)
- below = np.log(-scaling*x*(x<=0)+1)
- x = np.nan_to_num(above) - np.nan_to_num(below)
- return x / 2. + baseline
- fig, (ax, ax1) = plt.subplots(1, 2)
- ax.plot(x, y, color='C0')
- ax.plot(x, z, color='C1')
- yticks = np.linspace(0, 1, 11)
- ax.set_yticks(yticks)
- ax.set_yticklabels(['.%.2f' % i for i in yticks])
- ax.set_title('original')
- ax1.plot(x, jr_transform(y), color='C0')
- ax1.plot(x, jr_transform(z), color='C1')
- ax1.set_yticks(jr_transform(yticks))
- ax1.set_yticklabels(['.%.2f' % i for i in yticks])
- ax1.set_title('log')
- plt.show()
Add Comment
Please, Sign In to add comment