|
34 | 34 | from matplotlib.container import BarContainer, ErrorbarContainer, StemContainer
|
35 | 35 | from matplotlib.axes._base import _AxesBase
|
36 | 36 |
|
| 37 | +from . import _lines |
| 38 | + |
37 | 39 | iterable = cbook.iterable
|
38 | 40 | is_string_like = cbook.is_string_like
|
39 | 41 | is_sequence_of_strings = cbook.is_sequence_of_strings
|
@@ -591,77 +593,9 @@ def annotate(self, *args, **kwargs):
|
591 | 593 |
|
592 | 594 | #### Lines and spans
|
593 | 595 |
|
594 |
| - @docstring.dedent_interpd |
595 | 596 | def axhline(self, y=0, xmin=0, xmax=1, **kwargs):
|
596 |
| - """ |
597 |
| - Add a horizontal line across the axis. |
598 |
| -
|
599 |
| - Parameters |
600 |
| - ---------- |
601 |
| - y : scalar, optional, default: 0 |
602 |
| - y position in data coordinates of the horizontal line. |
603 |
| -
|
604 |
| - xmin : scalar, optional, default: 0 |
605 |
| - Should be between 0 and 1, 0 being the far left of the plot, 1 the |
606 |
| - far right of the plot. |
607 |
| -
|
608 |
| - xmax : scalar, optional, default: 1 |
609 |
| - Should be between 0 and 1, 0 being the far left of the plot, 1 the |
610 |
| - far right of the plot. |
611 |
| -
|
612 |
| - Returns |
613 |
| - ------- |
614 |
| - `~matplotlib.lines.Line2D` |
615 |
| -
|
616 |
| - Notes |
617 |
| - ----- |
618 |
| - kwargs are the same as kwargs to plot, and can be |
619 |
| - used to control the line properties. e.g., |
620 |
| -
|
621 |
| - Examples |
622 |
| - -------- |
623 |
| -
|
624 |
| - * draw a thick red hline at 'y' = 0 that spans the xrange:: |
625 |
| -
|
626 |
| - >>> axhline(linewidth=4, color='r') |
627 |
| -
|
628 |
| - * draw a default hline at 'y' = 1 that spans the xrange:: |
629 |
| -
|
630 |
| - >>> axhline(y=1) |
631 |
| -
|
632 |
| - * draw a default hline at 'y' = .5 that spans the the middle half of |
633 |
| - the xrange:: |
634 |
| -
|
635 |
| - >>> axhline(y=.5, xmin=0.25, xmax=0.75) |
636 |
| -
|
637 |
| - Valid kwargs are :class:`~matplotlib.lines.Line2D` properties, |
638 |
| - with the exception of 'transform': |
639 |
| -
|
640 |
| - %(Line2D)s |
641 |
| -
|
642 |
| - See also |
643 |
| - -------- |
644 |
| - `axhspan` for example plot and source code |
645 |
| - """ |
646 |
| - |
647 |
| - if "transform" in kwargs: |
648 |
| - raise ValueError( |
649 |
| - "'transform' is not allowed as a kwarg;" |
650 |
| - + "axhline generates its own transform.") |
651 |
| - ymin, ymax = self.get_ybound() |
652 |
| - |
653 |
| - # We need to strip away the units for comparison with |
654 |
| - # non-unitized bounds |
655 |
| - self._process_unit_info(ydata=y, kwargs=kwargs) |
656 |
| - yy = self.convert_yunits(y) |
657 |
| - scaley = (yy < ymin) or (yy > ymax) |
658 |
| - |
659 |
| - trans = mtransforms.blended_transform_factory( |
660 |
| - self.transAxes, self.transData) |
661 |
| - l = mlines.Line2D([xmin, xmax], [y, y], transform=trans, **kwargs) |
662 |
| - self.add_line(l) |
663 |
| - self.autoscale_view(scalex=False, scaley=scaley) |
664 |
| - return l |
| 597 | + return _lines.axhline(self, y=0, xmin=0, xmax=1, **kwargs) |
| 598 | + axhline.__doc__ = _lines.axhline.__doc__ |
665 | 599 |
|
666 | 600 | @docstring.dedent_interpd
|
667 | 601 | def axvline(self, x=0, ymin=0, ymax=1, **kwargs):
|
|
0 commit comments