|
20 | 20 |
|
21 | 21 | .. math:: |
22 | 22 |
|
23 | | - a \\rightarrow a_0 \\ln (a) + {\\cal O}(1) |
| 23 | + a \\rightarrow a_0 \\, {\\rm sgn}(a) \\ln |a| + {\\cal O}(1) |
24 | 24 |
|
25 | 25 | As with the `symlog` scaling, this allows one to plot quantities |
26 | 26 | that cover a very wide dynamic range that includes both positive |
27 | 27 | and negative values. However, `symlog` involves a tranformation |
28 | 28 | that has discontinuities in its gradient because it is built |
29 | | -from *separate* linear and logarithmic transformation. |
| 29 | +from *separate* linear and logarithmic transformations. |
30 | 30 | The `asinh` scaling uses a transformation that is smooth |
31 | 31 | for all (finite) values, which is both mathematically cleaner |
32 | 32 | and should reduce visual artifacts associated with an abrupt |
|
35 | 35 | See `~.scale.AsinhScale`, `~.scale.SymmetricalLogScale`. |
36 | 36 | """ |
37 | 37 |
|
38 | | -import numpy |
| 38 | +import numpy as np |
39 | 39 | import matplotlib.pyplot as plt |
40 | 40 |
|
41 | 41 | # Prepare sample values for variations on y=x graph: |
42 | | -x = numpy.linspace(-3, 6, 100) |
| 42 | +x = np.linspace(-3, 6, 100) |
43 | 43 |
|
44 | 44 | ######################################## |
45 | | -# Compare "symlog" and "asinh" behaviour on sample y=x graph: |
| 45 | +# Compare "symlog" and "asinh" behaviour on sample y=x graph, |
| 46 | +# where the discontinuous gradient in "symlog" near y=2 is obvious: |
46 | 47 | fig1 = plt.figure() |
47 | 48 | ax0, ax1 = fig1.subplots(1, 2, sharex=True) |
48 | 49 |
|
|
73 | 74 |
|
74 | 75 | ######################################## |
75 | 76 | # Compare "symlog" and "asinh" scalings |
76 | | -# on 2D Cauchy-distributed random numbers: |
| 77 | +# on 2D Cauchy-distributed random numbers, |
| 78 | +# where one may be able to see more subtle artifacts near y=2 |
| 79 | +# due to the gradient-discontinuity in "symlog": |
77 | 80 | fig3 = plt.figure() |
78 | 81 | ax = fig3.subplots(1, 1) |
79 | | -r = numpy.tan(numpy.random.uniform(-numpy.pi / 2.02, numpy.pi / 2.02, |
80 | | - size=(5000,))) |
81 | | -th = numpy.random.uniform(0, 2*numpy.pi, size=r.shape) |
| 82 | +r = 3 * np.tan(np.random.uniform(-np.pi / 2.01, np.pi / 2.01, |
| 83 | + size=(5000,))) |
| 84 | +th = np.random.uniform(0, 2*np.pi, size=r.shape) |
82 | 85 |
|
83 | | -ax.scatter(r * numpy.cos(th), r * numpy.sin(th), s=4, alpha=0.5) |
| 86 | +ax.scatter(r * np.cos(th), r * np.sin(th), s=4, alpha=0.5) |
84 | 87 | ax.set_xscale('asinh') |
85 | 88 | ax.set_yscale('symlog') |
86 | 89 | ax.set_xlabel('asinh') |
87 | 90 | ax.set_ylabel('symlog') |
88 | 91 | ax.set_title('2D Cauchy random deviates') |
| 92 | +ax.set_xlim(-50, 50) |
| 93 | +ax.set_ylim(-50, 50) |
89 | 94 | ax.grid() |
90 | 95 |
|
91 | 96 |
|
|
0 commit comments