MCPcopy
hub / github.com/matplotlib/matplotlib / axhline

Method axhline

lib/matplotlib/axes/_axes.py:748–828  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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)

Callers 15

xcorrMethod · 0.95
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
axhlineFunction · 0.80
test_axhlineFunction · 0.80
test_date_axhlineFunction · 0.80
test_date_inverted_limitFunction · 0.80
test_usetexFunction · 0.80
test_use14corefontsFunction · 0.80
test_log_scalesFunction · 0.80
test_useafmFunction · 0.80

Calls 7

_check_no_unitsMethod · 0.95
get_pathMethod · 0.95
get_yboundMethod · 0.80
_process_unit_infoMethod · 0.80
add_lineMethod · 0.80
get_yaxis_transformMethod · 0.45

Tested by 15

test_axhlineFunction · 0.64
test_date_axhlineFunction · 0.64
test_date_inverted_limitFunction · 0.64
test_usetexFunction · 0.64
test_use14corefontsFunction · 0.64
test_log_scalesFunction · 0.64
test_useafmFunction · 0.64
test_numpy_facadeFunction · 0.64
test_axhlineMethod · 0.64
test_acorrFunction · 0.64