Add a horizontal line spanning the whole or fraction of the Axes. Note: If you want to set x-limits in data coordinates, use `~.Axes.hlines` instead. Parameters ---------- y : float, default: 0 y position in :ref:`data coordinates <coord
(self, y=0, xmin=0, xmax=1, **kwargs)
| 746 | |
| 747 | @_docstring.interpd |
| 748 | def axhline(self, y=0, xmin=0, xmax=1, **kwargs): |
| 749 | """ |
| 750 | Add a horizontal line spanning the whole or fraction of the Axes. |
| 751 | |
| 752 | Note: If you want to set x-limits in data coordinates, use |
| 753 | `~.Axes.hlines` instead. |
| 754 | |
| 755 | Parameters |
| 756 | ---------- |
| 757 | y : float, default: 0 |
| 758 | y position in :ref:`data coordinates <coordinate-systems>`. |
| 759 | |
| 760 | xmin : float, default: 0 |
| 761 | The start x-position in :ref:`axes coordinates <coordinate-systems>`. |
| 762 | Should be between 0 and 1, 0 being the far left of the plot, |
| 763 | 1 the far right of the plot. |
| 764 | |
| 765 | xmax : float, default: 1 |
| 766 | The end x-position in :ref:`axes coordinates <coordinate-systems>`. |
| 767 | Should be between 0 and 1, 0 being the far left of the plot, |
| 768 | 1 the far right of the plot. |
| 769 | |
| 770 | Returns |
| 771 | ------- |
| 772 | `~matplotlib.lines.Line2D` |
| 773 | A `.Line2D` specified via two points ``(xmin, y)``, ``(xmax, y)``. |
| 774 | Its transform is set such that *x* is in |
| 775 | :ref:`axes coordinates <coordinate-systems>` and *y* is in |
| 776 | :ref:`data coordinates <coordinate-systems>`. |
| 777 | |
| 778 | This is still a generic line and the horizontal character is only |
| 779 | realized through using identical *y* values for both points. Thus, |
| 780 | if you want to change the *y* value later, you have to provide two |
| 781 | values ``line.set_ydata([3, 3])``. |
| 782 | |
| 783 | Other Parameters |
| 784 | ---------------- |
| 785 | **kwargs |
| 786 | Valid keyword arguments are `.Line2D` properties, except for |
| 787 | 'transform': |
| 788 | |
| 789 | %(Line2D:kwdoc)s |
| 790 | |
| 791 | See Also |
| 792 | -------- |
| 793 | hlines : Add horizontal lines in data coordinates. |
| 794 | axhspan : Add a horizontal span (rectangle) across the axis. |
| 795 | axline : Add a line with an arbitrary slope. |
| 796 | |
| 797 | Examples |
| 798 | -------- |
| 799 | * draw a thick red hline at 'y' = 0 that spans the xrange:: |
| 800 | |
| 801 | >>> axhline(linewidth=4, color='r') |
| 802 | |
| 803 | * draw a default hline at 'y' = 1 that spans the xrange:: |
| 804 | |
| 805 | >>> axhline(y=1) |