Skip to content

Commit

Permalink
Fix formatting in docstring for dates
Browse files Browse the repository at this point in the history
  • Loading branch information
jenshnielsen committed Sep 16, 2014
1 parent 81760d7 commit 5b2ff4f
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions lib/matplotlib/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,22 +520,22 @@ class AutoDateFormatter(ticker.Formatter):
>>> formatter = AutoDateFormatter()
>>> formatter.scaled[1/(24.*60.)] = '%M:%S' # only show min and sec
Custom `FunctionFormatter`s can also be used. The following example shows
A Custom :class:`~matplotlib.ticker.FuncFormatter` can also be used. The following example shows
how to use a custom format function to strip trailing zeros from decimal
seconds and adds the date to the first ticklabel::
>>> def my_format_function(x, pos=None):
... x = matplotlib.dates.num2date(x)
... if pos == 0:
... fmt = '%D %H:%M:%S.%f'
... else:
... fmt = '%H:%M:%S.%f'
... label = x.strftime(fmt)
... label = label.rstrip("0")
... label = label.rstrip(".")
... return label
>>> from matplotlib.ticker import FuncFormatter
>>> formatter.scaled[1/(24.*60.)] = FuncFormatter(my_format_function)
>>> def my_format_function(x, pos=None):
... x = matplotlib.dates.num2date(x)
... if pos == 0:
... fmt = '%D %H:%M:%S.%f'
... else:
... fmt = '%H:%M:%S.%f'
... label = x.strftime(fmt)
... label = label.rstrip("0")
... label = label.rstrip(".")
... return label
>>> from matplotlib.ticker import FuncFormatter
>>> formatter.scaled[1/(24.*60.)] = FuncFormatter(my_format_function)
"""

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

0 comments on commit 5b2ff4f

Please sign in to comment.