Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit73e44cc

Browse files
committed
Also templatize x/y/zaxis_date.
1 parent5350e8a commit73e44cc

File tree

3 files changed

+17
-43
lines changed

3 files changed

+17
-43
lines changed

‎lib/matplotlib/axes/_base.py

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
fromcollectionsimportOrderedDict
22
fromcontextlibimportExitStack
33
importfunctools
4+
importinspect
45
importitertools
56
importlogging
67
importmath
@@ -44,7 +45,8 @@ def _axis_method_wrapper(attr_name, method_name, *, doc_sub=None):
4445
4546
The docstring of ``get_foo`` is built by replacing "this Axis" by "the
4647
{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.
4850
"""
4951

5052
method=getattr(maxis.Axis,method_name)
@@ -62,7 +64,7 @@ def wrapper(self, *args, **kwargs):
6264
(f"The docstring of wrapped Axis method{method_name!r} must "
6365
f"contain{k!r} as a substring.")
6466
doc=doc.replace(k,v)
65-
wrapper.__doc__=doc
67+
wrapper.__doc__=inspect.cleandoc(doc)
6668

6769
returnwrapper
6870

@@ -3635,29 +3637,8 @@ def set_yscale(self, value, **kwargs):
36353637
"yaxis","_set_ticklabels",
36363638
doc_sub={"Axis.set_ticks":"Axes.set_yticks"})
36373639

3638-
defxaxis_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-
defyaxis_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")
36613642

36623643
defformat_xdata(self,x):
36633644
"""

‎lib/matplotlib/axis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,11 +1752,11 @@ def zoom(self, direction):
17521752

17531753
defaxis_date(self,tz=None):
17541754
"""
1755-
Sets up axis ticks and labelstreatingdata along thisaxis as dates.
1755+
Sets up axis ticks and labelsto treatdata along thisAxis as dates.
17561756
17571757
Parameters
17581758
----------
1759-
tz :tzinfo orstr or None
1759+
tz :str or`datetime.tzinfo`, default: :rc:`timezone`
17601760
The timezone used to create date labels.
17611761
"""
17621762
# By providing a sample datetime instance with the desired timezone,

‎lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
fromcollectionsimportdefaultdict
1414
fromfunctoolsimportreduce
1515
importmath
16+
importtextwrap
1617

1718
importnumpyasnp
1819

@@ -830,23 +831,15 @@ def set_zscale(self, value, **kwargs):
830831
"zaxis","_set_ticklabels",
831832
doc_sub={"Axis.set_ticks":"Axes.set_zticks"})
832833

833-
defzaxis_date(self,tz=None):
834-
"""
835-
Sets up z-axis ticks and labels that treat the z data as dates.
836-
837-
.. note::
838-
This function is merely provided for completeness.
839-
Axes3D objects do not officially support dates for ticks,
840-
and so this may or may not work as expected.
841-
842-
.. versionadded:: 1.1.0
843-
This function was added, but not tested. Please report any bugs.
834+
zaxis_date=_axis_method_wrapper("zaxis","axis_date")
835+
ifzaxis_date.__doc__:
836+
zaxis_date.__doc__+=textwrap.dedent("""
844837
845-
Parameters
846-
----------
847-
tz : `datetime.tzinfo`, default: :rc:`timezone`
848-
"""
849-
self.zaxis.axis_date(tz)
838+
Notes
839+
-----
840+
This function is merely provided for completeness, but 3d axes do not
841+
support dates for ticks, and so this may not work as expected.
842+
""")
850843

851844
defclabel(self,*args,**kwargs):
852845
"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp