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

Skip to content

Commit dc5b52a

Browse files
committed
ENH the axes class now uses mixins.
Lines and Spans function are set to be in a class. Axes now inherits from _AxesBase, and LinesAndSpans is a mixin
1 parent a9e035b commit dc5b52a

File tree

2 files changed

+328
-353
lines changed

2 files changed

+328
-353
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
# The axes module contains all the wrappers to plotting functions.
4444
# All the other methods should go in the _AxesBase class.
4545

46-
class Axes(_AxesBase):
46+
class Axes(_AxesBase, _lines.LinesAndSpans):
4747
"""
4848
The :class:`Axes` contains most of the figure elements:
4949
:class:`~matplotlib.axis.Axis`, :class:`~matplotlib.axis.Tick`,
@@ -57,6 +57,7 @@ class Axes(_AxesBase):
5757
'ylim_changed' and the callback will be called with func(*ax*)
5858
where *ax* is the :class:`Axes` instance.
5959
"""
60+
6061
### Labelling, legend and texts
6162

6263
def get_title(self, loc="center"):
@@ -590,35 +591,6 @@ def annotate(self, *args, **kwargs):
590591
a._remove_method = lambda h: self.texts.remove(h)
591592
return a
592593

593-
#### Lines and spans
594-
595-
def axhline(self, y=0, xmin=0, xmax=1, **kwargs):
596-
return _lines.axhline(self, y=0, xmin=0, xmax=1, **kwargs)
597-
axhline.__doc__ = _lines.axhline.__doc__
598-
599-
def axvline(self, x=0, ymin=0, ymax=1, **kwargs):
600-
return _lines.axvline(self, x=0, ymin=0, ymax=1, **kwargs)
601-
axvline.__doc__ = _lines.axvline.__doc__
602-
603-
def axhspan(self, ymin, ymax, xmin=0, xmax=1, **kwargs):
604-
return _lines.axhspan(self, ymin, ymax, xmin=0, xmax=1, **kwargs)
605-
axhspan.__doc__ = _lines.axhspan.__doc__
606-
607-
def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs):
608-
return _lines.axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs)
609-
axvspan.__doc__ = _lines.axvspan.__doc__
610-
611-
def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
612-
label='', **kwargs):
613-
return _lines.hlines(self, y, xmin, xmax, colors='k',
614-
linestyles='solid', label='', **kwargs)
615-
hlines.__doc__ = _lines.hlines.__doc__
616-
617-
def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
618-
label='', **kwargs):
619-
return _lines.vlines.__doc__
620-
vlines.__doc__ = _lines.vlines.__doc__
621-
622594
@docstring.dedent_interpd
623595
def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
624596
linelengths=1, linewidths=None, colors=None,

0 commit comments

Comments
 (0)