Skip to content

Commit ae57d8d

Browse files
committed
Further refinements to documentation and test coverage
1 parent 8d7c2ad commit ae57d8d

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

doc/api/colors_api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Classes
2121
:toctree: _as_gen/
2222
:template: autosummary.rst
2323

24+
AsinhNorm
2425
BoundaryNorm
2526
Colormap
2627
CenteredNorm

lib/matplotlib/colors.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,6 +1662,12 @@ class AsinhNorm(Normalize):
16621662
or negative values. Unlike the `SymLogNorm`, the transition between
16631663
these linear and logarithmic regions is smooth, which may reduce
16641664
the risk of visual artifacts.
1665+
1666+
Parameters
1667+
----------
1668+
linear_width : float, default: 1
1669+
The effective width of the linear region, beyond which
1670+
the transformation becomes asymptotically logarithmic
16651671
"""
16661672

16671673
@property

lib/matplotlib/tests/test_scale.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
LogTransform, InvertedLogTransform,
77
SymmetricalLogTransform)
88
import matplotlib.scale as mscale
9+
from matplotlib.ticker import AsinhLocator, LogFormatterSciNotation
910
from matplotlib.testing.decorators import check_figures_equal, image_comparison
1011

1112
import numpy as np
@@ -261,6 +262,28 @@ def test_base_init(self):
261262
assert s7._base == 7
262263
assert s7._subs == (2, 4)
263264

265+
def test_fmtloc(self):
266+
class DummyAxis:
267+
def __init__(self):
268+
self.fields = {}
269+
def set(self, **kwargs):
270+
self.fields.update(**kwargs)
271+
def set_major_formatter(self, f):
272+
self.fields['major_formatter'] = f
273+
274+
ax0 = DummyAxis()
275+
s0 = AsinhScale(axis=ax0, base=0)
276+
s0.set_default_locators_and_formatters(ax0)
277+
assert isinstance(ax0.fields['major_locator'], AsinhLocator)
278+
assert isinstance(ax0.fields['major_formatter'], str)
279+
280+
ax5 = DummyAxis()
281+
s7 = AsinhScale(axis=ax5, base=5)
282+
s7.set_default_locators_and_formatters(ax5)
283+
assert isinstance(ax5.fields['major_locator'], AsinhLocator)
284+
assert isinstance(ax5.fields['major_formatter'],
285+
LogFormatterSciNotation)
286+
264287
def test_bad_scale(self):
265288
fig, ax = plt.subplots()
266289

0 commit comments

Comments
 (0)