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

Skip to content

Commit 5b2ff4f

Browse files
committed
Fix formatting in docstring for dates
1 parent 81760d7 commit 5b2ff4f

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

lib/matplotlib/dates.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -520,22 +520,22 @@ 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
523+
A Custom :class:`~matplotlib.ticker.FuncFormatter` can also be used. The following example shows
524524
how to use a custom format function to strip trailing zeros from decimal
525525
seconds and adds the date to the first ticklabel::
526526
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)
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)
539539
"""
540540

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

0 commit comments

Comments
 (0)