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

Skip to content

Commit 630f867

Browse files
committed
Fix formatting in docstring for dates
1 parent 81760d7 commit 630f867

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

lib/matplotlib/dates.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -520,22 +520,23 @@ class AutoDateFormatter(ticker.Formatter):
520520
>>> formatter = AutoDateFormatter()
521521
>>> formatter.scaled[1/(24.*60.)] = '%M:%S' # only show min and sec
522522
523-
Custom `FunctionFormatter`s can also be used. The following example shows
524-
how to use a custom format function to strip trailing zeros from decimal
525-
seconds and adds the date to the first ticklabel::
526-
527-
>>> def my_format_function(x, pos=None):
528-
... x = matplotlib.dates.num2date(x)
529-
... if pos == 0:
530-
... fmt = '%D %H:%M:%S.%f'
531-
... else:
532-
... fmt = '%H:%M:%S.%f'
533-
... label = x.strftime(fmt)
534-
... label = label.rstrip("0")
535-
... label = label.rstrip(".")
536-
... return label
537-
>>> from matplotlib.ticker import FuncFormatter
538-
>>> formatter.scaled[1/(24.*60.)] = FuncFormatter(my_format_function)
523+
A custom :class:`~matplotlib.ticker.FuncFormatter` can also be used.
524+
The following example shows how to use a custom format function to strip
525+
trailing zeros from decimal seconds and adds the date to the first
526+
ticklabel::
527+
528+
>>> def my_format_function(x, pos=None):
529+
... x = matplotlib.dates.num2date(x)
530+
... if pos == 0:
531+
... fmt = '%D %H:%M:%S.%f'
532+
... else:
533+
... fmt = '%H:%M:%S.%f'
534+
... label = x.strftime(fmt)
535+
... label = label.rstrip("0")
536+
... label = label.rstrip(".")
537+
... return label
538+
>>> from matplotlib.ticker import FuncFormatter
539+
>>> formatter.scaled[1/(24.*60.)] = FuncFormatter(my_format_function)
539540
"""
540541

541542
# This can be improved by providing some user-level direction on

0 commit comments

Comments
 (0)