Plot vertical lines at each *x* from *ymin* to *ymax*. Parameters ---------- x : float or array-like x-indexes where to plot the lines. ymin, ymax : float or array-like Respective beginning and end of each line. If scalars are
(self, x, ymin, ymax, colors=None, linestyles='solid',
label='', **kwargs)
| 1206 | @_preprocess_data(replace_names=["x", "ymin", "ymax", "colors"], |
| 1207 | label_namer="x") |
| 1208 | def vlines(self, x, ymin, ymax, colors=None, linestyles='solid', |
| 1209 | label='', **kwargs): |
| 1210 | """ |
| 1211 | Plot vertical lines at each *x* from *ymin* to *ymax*. |
| 1212 | |
| 1213 | Parameters |
| 1214 | ---------- |
| 1215 | x : float or array-like |
| 1216 | x-indexes where to plot the lines. |
| 1217 | |
| 1218 | ymin, ymax : float or array-like |
| 1219 | Respective beginning and end of each line. If scalars are |
| 1220 | provided, all lines will have the same length. |
| 1221 | |
| 1222 | colors : :mpltype:`color` or list of color, default: :rc:`lines.color` |
| 1223 | |
| 1224 | linestyles : {'solid', 'dashed', 'dashdot', 'dotted'}, default: 'solid' |
| 1225 | |
| 1226 | label : str, default: '' |
| 1227 | |
| 1228 | Returns |
| 1229 | ------- |
| 1230 | `~matplotlib.collections.LineCollection` |
| 1231 | |
| 1232 | Other Parameters |
| 1233 | ---------------- |
| 1234 | data : indexable object, optional |
| 1235 | DATA_PARAMETER_PLACEHOLDER |
| 1236 | **kwargs : `~matplotlib.collections.LineCollection` properties. |
| 1237 | |
| 1238 | See Also |
| 1239 | -------- |
| 1240 | hlines : horizontal lines |
| 1241 | axvline : vertical line across the Axes |
| 1242 | """ |
| 1243 | |
| 1244 | # We do the conversion first since not all unitized data is uniform |
| 1245 | x, ymin, ymax = self._process_unit_info( |
| 1246 | [("x", x), ("y", ymin), ("y", ymax)], kwargs) |
| 1247 | |
| 1248 | if not np.iterable(x): |
| 1249 | x = [x] |
| 1250 | if not np.iterable(ymin): |
| 1251 | ymin = [ymin] |
| 1252 | if not np.iterable(ymax): |
| 1253 | ymax = [ymax] |
| 1254 | |
| 1255 | # Create and combine masked_arrays from input |
| 1256 | x, ymin, ymax = cbook._combine_masks(x, ymin, ymax) |
| 1257 | x = np.ravel(x) |
| 1258 | ymin = np.ravel(ymin) |
| 1259 | ymax = np.ravel(ymax) |
| 1260 | |
| 1261 | masked_verts = np.ma.empty((len(x), 2, 2)) |
| 1262 | masked_verts[:, 0, 0] = x |
| 1263 | masked_verts[:, 0, 1] = ymin |
| 1264 | masked_verts[:, 1, 0] = x |
| 1265 | masked_verts[:, 1, 1] = ymax |