Plot horizontal lines at each *y* from *xmin* to *xmax*. Parameters ---------- y : float or array-like y-indexes where to plot the lines. xmin, xmax : float or array-like Respective beginning and end of each line. If scalars are
(self, y, xmin, xmax, colors=None, linestyles='solid',
label='', **kwargs)
| 1114 | @_preprocess_data(replace_names=["y", "xmin", "xmax", "colors"], |
| 1115 | label_namer="y") |
| 1116 | def hlines(self, y, xmin, xmax, colors=None, linestyles='solid', |
| 1117 | label='', **kwargs): |
| 1118 | """ |
| 1119 | Plot horizontal lines at each *y* from *xmin* to *xmax*. |
| 1120 | |
| 1121 | Parameters |
| 1122 | ---------- |
| 1123 | y : float or array-like |
| 1124 | y-indexes where to plot the lines. |
| 1125 | |
| 1126 | xmin, xmax : float or array-like |
| 1127 | Respective beginning and end of each line. If scalars are |
| 1128 | provided, all lines will have the same length. |
| 1129 | |
| 1130 | colors : :mpltype:`color` or list of color , default: :rc:`lines.color` |
| 1131 | |
| 1132 | linestyles : {'solid', 'dashed', 'dashdot', 'dotted'}, default: 'solid' |
| 1133 | |
| 1134 | label : str, default: '' |
| 1135 | |
| 1136 | Returns |
| 1137 | ------- |
| 1138 | `~matplotlib.collections.LineCollection` |
| 1139 | |
| 1140 | Other Parameters |
| 1141 | ---------------- |
| 1142 | data : indexable object, optional |
| 1143 | DATA_PARAMETER_PLACEHOLDER |
| 1144 | **kwargs : `~matplotlib.collections.LineCollection` properties. |
| 1145 | |
| 1146 | See Also |
| 1147 | -------- |
| 1148 | vlines : vertical lines |
| 1149 | axhline : horizontal line across the Axes |
| 1150 | """ |
| 1151 | |
| 1152 | # We do the conversion first since not all unitized data is uniform |
| 1153 | xmin, xmax, y = self._process_unit_info( |
| 1154 | [("x", xmin), ("x", xmax), ("y", y)], kwargs) |
| 1155 | |
| 1156 | if not np.iterable(y): |
| 1157 | y = [y] |
| 1158 | if not np.iterable(xmin): |
| 1159 | xmin = [xmin] |
| 1160 | if not np.iterable(xmax): |
| 1161 | xmax = [xmax] |
| 1162 | |
| 1163 | # Create and combine masked_arrays from input |
| 1164 | y, xmin, xmax = cbook._combine_masks(y, xmin, xmax) |
| 1165 | y = np.ravel(y) |
| 1166 | xmin = np.ravel(xmin) |
| 1167 | xmax = np.ravel(xmax) |
| 1168 | |
| 1169 | masked_verts = np.ma.empty((len(y), 2, 2)) |
| 1170 | masked_verts[:, 0, 0] = xmin |
| 1171 | masked_verts[:, 0, 1] = y |
| 1172 | masked_verts[:, 1, 0] = xmax |
| 1173 | masked_verts[:, 1, 1] = y |