Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c250937

Browse files
committed
simplify docstrings
1 parent 97ce6d1 commit c250937

File tree

2 files changed

+17
-45
lines changed

2 files changed

+17
-45
lines changed

lib/matplotlib/axis.py

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,19 +1551,7 @@ def set_minor_formatter(self, formatter):
15511551
15521552
In addition to a `~matplotlib.ticker.Formatter` instance,
15531553
this also accepts a ``str`` or function.
1554-
1555-
For a ``str`` a `~matplotlib.ticker.StrMethodFormatter` is used.
1556-
The field used for the value must be labeled ``'x'`` and the field used
1557-
for the position must be labeled ``'pos'``.
1558-
See the `~matplotlib.ticker.StrMethodFormatter` documentation for
1559-
more information.
1560-
1561-
For a function a `~matplotlib.ticker.FuncFormatter` is used.
1562-
The function should take in two inputs (a tick value ``x`` and a
1563-
position ``pos``), and return a string containing the corresponding
1564-
tick label.
1565-
See the `~matplotlib.ticker.FuncFormatter` documentation for
1566-
more information.
1554+
See `.Axis.set_major_formatter` for more information.
15671555
15681556
Parameters
15691557
----------
@@ -1572,30 +1560,6 @@ def set_minor_formatter(self, formatter):
15721560
self._set_formatter(formatter, self.minor)
15731561

15741562
def _set_formatter(self, formatter, level):
1575-
"""
1576-
Set the formatter of the major or minor ticker.
1577-
1578-
In addition to a `~matplotlib.ticker.Formatter` instance,
1579-
this also accepts a ``str`` or function.
1580-
1581-
For a ``str`` a `~matplotlib.ticker.StrMethodFormatter` is used.
1582-
The field used for the value must be labeled ``'x'`` and the field used
1583-
for the position must be labeled ``'pos'``.
1584-
See the `~matplotlib.ticker.StrMethodFormatter` documentation for
1585-
more information.
1586-
1587-
For a function a `~matplotlib.ticker.FuncFormatter` is used.
1588-
The function should take in two inputs (a tick value ``x`` and a
1589-
position ``pos``), and return a string containing the corresponding
1590-
tick label.
1591-
See the `~matplotlib.ticker.FuncFormatter` documentation for
1592-
more information.
1593-
1594-
Parameters
1595-
----------
1596-
formatter : `~matplotlib.ticker.Formatter`, ``str``, or function
1597-
level : `self.major` or `self.minor`
1598-
"""
15991563
if isinstance(formatter, str):
16001564
formatter = mticker.StrMethodFormatter(formatter)
16011565
# Don't allow any other TickHelper to avoid easy-to-make errors,

lib/matplotlib/tests/test_axes.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,17 @@ def _formfunc(x, pos):
210210

211211
ax = plt.figure().subplots()
212212

213-
assert ax.xaxis.isDefault_majfmt == True
214-
assert ax.xaxis.isDefault_minfmt == True
213+
assert ax.xaxis.isDefault_majfmt
214+
assert ax.xaxis.isDefault_minfmt
215+
assert ax.yaxis.isDefault_majfmt
216+
assert ax.yaxis.isDefault_minfmt
215217

216218
ax.xaxis.set_major_formatter(_formfunc)
217219

218-
assert ax.xaxis.isDefault_majfmt == False
219-
assert ax.xaxis.isDefault_minfmt == True
220+
assert not ax.xaxis.isDefault_majfmt
221+
assert ax.xaxis.isDefault_minfmt
222+
assert ax.yaxis.isDefault_majfmt
223+
assert ax.yaxis.isDefault_minfmt
220224

221225
targ_funcformatter = mticker.FuncFormatter(_formfunc)
222226

@@ -231,13 +235,17 @@ def test_strmethodformatter_auto_formatter():
231235

232236
ax = plt.figure().subplots()
233237

234-
assert ax.yaxis.isDefault_majfmt == True
235-
assert ax.yaxis.isDefault_minfmt == True
238+
assert ax.xaxis.isDefault_majfmt
239+
assert ax.xaxis.isDefault_minfmt
240+
assert ax.yaxis.isDefault_majfmt
241+
assert ax.yaxis.isDefault_minfmt
236242

237243
ax.yaxis.set_minor_formatter(formstr)
238244

239-
assert ax.yaxis.isDefault_majfmt == True
240-
assert ax.yaxis.isDefault_minfmt == False
245+
assert ax.xaxis.isDefault_majfmt
246+
assert ax.xaxis.isDefault_minfmt
247+
assert ax.yaxis.isDefault_majfmt
248+
assert not ax.yaxis.isDefault_minfmt
241249

242250
targ_strformatter = mticker.StrMethodFormatter(formstr)
243251

0 commit comments

Comments
 (0)