|
10 | 10 | rcParams = matplotlib.rcParams
|
11 | 11 |
|
12 | 12 | import matplotlib.cbook as cbook
|
13 |
| -from matplotlib.cbook import _string_to_bool |
14 | 13 | import matplotlib.collections as mcoll
|
15 | 14 | import matplotlib.colors as mcolors
|
16 | 15 | import matplotlib.contour as mcontour
|
@@ -780,90 +779,10 @@ def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs):
|
780 | 779 | @docstring.dedent
|
781 | 780 | def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
|
782 | 781 | label='', **kwargs):
|
783 |
| - """ |
784 |
| - Plot horizontal lines at each `y` from `xmin` to `xmax`. |
785 |
| -
|
786 |
| - Parameters |
787 |
| - ---------- |
788 |
| - y : scalar or sequence of scalar |
789 |
| - y-indexes where to plot the lines. |
790 |
| -
|
791 |
| - xmin, xmax : scalar or 1D array_like |
792 |
| - Respective beginning and end of each line. If scalars are |
793 |
| - provided, all lines will have same length. |
794 |
| -
|
795 |
| - colors : array_like of colors, optional, default: 'k' |
796 |
| -
|
797 |
| - linestyles : ['solid' | 'dashed' | 'dashdot' | 'dotted'], optional |
798 |
| -
|
799 |
| - label : string, optional, default: '' |
800 |
| -
|
801 |
| - Returns |
802 |
| - ------- |
803 |
| - lines : `~matplotlib.collections.LineCollection` |
804 |
| -
|
805 |
| - Other parameters |
806 |
| - ---------------- |
807 |
| - kwargs : `~matplotlib.collections.LineCollection` properties. |
808 |
| -
|
809 |
| - See also |
810 |
| - -------- |
811 |
| - vlines : vertical lines |
812 |
| -
|
813 |
| - Examples |
814 |
| - -------- |
815 |
| - .. plot:: mpl_examples/pylab_examples/vline_hline_demo.py |
816 |
| -
|
817 |
| - """ |
818 |
| - |
819 |
| - # We do the conversion first since not all unitized data is uniform |
820 |
| - # process the unit information |
821 |
| - self._process_unit_info([xmin, xmax], y, kwargs=kwargs) |
822 |
| - y = self.convert_yunits(y) |
823 |
| - xmin = self.convert_xunits(xmin) |
824 |
| - xmax = self.convert_xunits(xmax) |
825 |
| - |
826 |
| - if not iterable(y): |
827 |
| - y = [y] |
828 |
| - if not iterable(xmin): |
829 |
| - xmin = [xmin] |
830 |
| - if not iterable(xmax): |
831 |
| - xmax = [xmax] |
832 |
| - |
833 |
| - y = np.asarray(y) |
834 |
| - xmin = np.asarray(xmin) |
835 |
| - xmax = np.asarray(xmax) |
836 |
| - |
837 |
| - if len(xmin) == 1: |
838 |
| - xmin = np.resize(xmin, y.shape) |
839 |
| - if len(xmax) == 1: |
840 |
| - xmax = np.resize(xmax, y.shape) |
841 |
| - |
842 |
| - if len(xmin) != len(y): |
843 |
| - raise ValueError('xmin and y are unequal sized sequences') |
844 |
| - if len(xmax) != len(y): |
845 |
| - raise ValueError('xmax and y are unequal sized sequences') |
846 |
| - |
847 |
| - verts = [((thisxmin, thisy), (thisxmax, thisy)) |
848 |
| - for thisxmin, thisxmax, thisy in zip(xmin, xmax, y)] |
849 |
| - coll = mcoll.LineCollection(verts, colors=colors, |
850 |
| - linestyles=linestyles, label=label) |
851 |
| - self.add_collection(coll) |
852 |
| - coll.update(kwargs) |
853 |
| - |
854 |
| - if len(y) > 0: |
855 |
| - minx = min(xmin.min(), xmax.min()) |
856 |
| - maxx = max(xmin.max(), xmax.max()) |
857 |
| - miny = y.min() |
858 |
| - maxy = y.max() |
859 |
| - |
860 |
| - corners = (minx, miny), (maxx, maxy) |
861 |
| - |
862 |
| - self.update_datalim(corners) |
863 |
| - self.autoscale_view() |
864 |
| - |
865 |
| - return coll |
866 |
| - |
| 782 | + return _lines.hlines(self, y, xmin, xmax, colors='k', |
| 783 | + linestyles='solid', label='', **kwargs) |
| 784 | + hlines.__doc__ = _lines.hlines.__doc__ |
| 785 | + |
867 | 786 | @docstring.dedent_interpd
|
868 | 787 | def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
|
869 | 788 | label='', **kwargs):
|
|
0 commit comments