Skip to content

Commit 3f69788

Browse files
committed
Added demo script for asinh axis scaling
1 parent 9680432 commit 3f69788

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
New axis scale ``asinh``
2+
------------------------
3+
4+
The new ``asinh`` axis scale offers an alternative to ``symlog`` that
5+
smoothly transitions between the quasi-linear and asymptotically logarithmic
6+
regions of the scale. This is based on an arcsinh transformation that
7+
allows plotting both positive and negative values than span many orders
8+
of magnitude. A scale parameter ``a0`` is provided to allow the user
9+
to tune the width of the linear region of the scale.

examples/scales/asinh_demo.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""
2+
============
3+
Asinh Demo
4+
============
5+
"""
6+
7+
import numpy
8+
import matplotlib.pyplot as plt
9+
10+
# Prepare sample values for variations on y=x graph:
11+
x = numpy.linspace(-3, 6, 100)
12+
13+
# Compare "symlog" and "asinh" behaviour on sample y=x graph:
14+
fig1 = plt.figure()
15+
ax0, ax1 = fig1.subplots(1, 2, sharex=True)
16+
17+
ax0.plot(x, x)
18+
ax0.set_yscale('symlog')
19+
ax0.grid()
20+
ax0.set_title('symlog')
21+
22+
ax1.plot(x, x)
23+
ax1.set_yscale('asinh')
24+
ax1.grid()
25+
ax1.set_title(r'$sinh^{-1}$')
26+
27+
28+
# Compare "asinh" graphs with different scale parameter "a0":
29+
fig2 = plt.figure()
30+
axs = fig2.subplots(1, 3, sharex=True)
31+
for ax, a0 in zip(axs, (0.2, 1.0, 5.0)):
32+
ax.set_title('a0={:.3g}'.format(a0))
33+
ax.plot(x, x, label='y=x')
34+
ax.plot(x, 10*x, label='y=10x')
35+
ax.plot(x, 100*x, label='y=100x')
36+
ax.set_yscale('asinh', a0=a0)
37+
ax.grid()
38+
ax.legend(loc='best', fontsize='small')
39+
40+
plt.show()

0 commit comments

Comments
 (0)