1
1
from collections import OrderedDict
2
2
from contextlib import ExitStack
3
3
import functools
4
+ import inspect
4
5
import itertools
5
6
import logging
6
7
import math
@@ -44,7 +45,8 @@ def _axis_method_wrapper(attr_name, method_name, *, doc_sub=None):
44
45
45
46
The docstring of ``get_foo`` is built by replacing "this Axis" by "the
46
47
{attr_name}" ("the xaxis", "the yaxis") in the wrapped method's docstring;
47
- additional replacements can by given in *doc_sub*.
48
+ additional replacements can by given in *doc_sub*. The docstring is also
49
+ dedented to simplify further manipulations.
48
50
"""
49
51
50
52
method = getattr (maxis .Axis , method_name )
@@ -62,7 +64,7 @@ def wrapper(self, *args, **kwargs):
62
64
(f"The docstring of wrapped Axis method { method_name !r} must "
63
65
f"contain { k !r} as a substring." )
64
66
doc = doc .replace (k , v )
65
- wrapper .__doc__ = doc
67
+ wrapper .__doc__ = inspect . cleandoc ( doc )
66
68
67
69
return wrapper
68
70
@@ -3635,29 +3637,8 @@ def set_yscale(self, value, **kwargs):
3635
3637
"yaxis" , "_set_ticklabels" ,
3636
3638
doc_sub = {"Axis.set_ticks" : "Axes.set_yticks" })
3637
3639
3638
- def xaxis_date (self , tz = None ):
3639
- """
3640
- Sets up x-axis ticks and labels that treat the x data as dates.
3641
-
3642
- Parameters
3643
- ----------
3644
- tz : str or `datetime.tzinfo`, default: :rc:`timezone`
3645
- Timezone.
3646
- """
3647
- # should be enough to inform the unit conversion interface
3648
- # dates are coming in
3649
- self .xaxis .axis_date (tz )
3650
-
3651
- def yaxis_date (self , tz = None ):
3652
- """
3653
- Sets up y-axis ticks and labels that treat the y data as dates.
3654
-
3655
- Parameters
3656
- ----------
3657
- tz : str or `datetime.tzinfo`, default: :rc:`timezone`
3658
- Timezone.
3659
- """
3660
- self .yaxis .axis_date (tz )
3640
+ xaxis_date = _axis_method_wrapper ("xaxis" , "axis_date" )
3641
+ yaxis_date = _axis_method_wrapper ("yaxis" , "axis_date" )
3661
3642
3662
3643
def format_xdata (self , x ):
3663
3644
"""
0 commit comments