MCPcopy
hub / github.com/matplotlib/matplotlib / hlines

Method hlines

lib/matplotlib/axes/_axes.py:1116–1203  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 11

hlinesFunction · 0.80
test_hlinesMethod · 0.80
test_hlinesFunction · 0.80
test_hlines_defaultFunction · 0.80
test_lines_with_colorsFunction · 0.80
test_nn_pixel_alignmentFunction · 0.80
colors.pyFile · 0.80

Calls 8

_process_unit_infoMethod · 0.80
add_collectionMethod · 0.80
_internal_updateMethod · 0.80
get_datalimMethod · 0.45
get_transformMethod · 0.45
update_datalimMethod · 0.45

Tested by 8

test_hlinesMethod · 0.64
test_hlinesFunction · 0.64
test_hlines_defaultFunction · 0.64
test_lines_with_colorsFunction · 0.64
test_nn_pixel_alignmentFunction · 0.64