@@ -184,13 +184,20 @@ def to_rgba(c, alpha=None):
184
184
c : Matplotlib color or ``np.ma.masked``
185
185
186
186
alpha : float, optional
187
- If *alpha* is not ``None``, it forces the alpha value, except if *c* is
188
- ``"none"`` (case-insensitive), which always maps to ``(0, 0, 0, 0)``.
187
+ If *alpha* is given, force the alpha value of the returned RGBA tuple
188
+ to *alpha*.
189
+
190
+ If None, the alpha value from *c* is used. If *c* does not have an
191
+ alpha channel, then alpha defaults to 1.
192
+
193
+ *alpha* is ignored for the color value ``"none"`` (case-insensitive),
194
+ which always maps to ``(0, 0, 0, 0)``.
189
195
190
196
Returns
191
197
-------
192
198
tuple
193
- Tuple of ``(r, g, b, a)`` scalars.
199
+ Tuple of floats ``(r, g, b, a)``, where each channel (red, green, blue,
200
+ alpha) can assume values between 0 and 1.
194
201
"""
195
202
# Special-case nth color syntax because it should not be cached.
196
203
if _is_nth_color (c ):
@@ -215,8 +222,12 @@ def _to_rgba_no_colorcycle(c, alpha=None):
215
222
"""
216
223
Convert *c* to an RGBA color, with no support for color-cycle syntax.
217
224
218
- If *alpha* is not ``None``, it forces the alpha value, except if *c* is
219
- ``"none"`` (case-insensitive), which always maps to ``(0, 0, 0, 0)``.
225
+ If *alpha* is given, force the alpha value of the returned RGBA tuple
226
+ to *alpha*. Otherwise, the alpha value from *c* is used, if it has alpha
227
+ information, or defaults to 1.
228
+
229
+ *alpha* is ignored for the color value ``"none"`` (case-insensitive),
230
+ which always maps to ``(0, 0, 0, 0)``.
220
231
"""
221
232
orig_c = c
222
233
if c is np .ma .masked :
@@ -310,16 +321,23 @@ def to_rgba_array(c, alpha=None):
310
321
row for each masked value or row in *c*.
311
322
312
323
alpha : float or sequence of floats, optional
313
- If *alpha* is not ``None``, it forces the alpha value, except if *c* is
314
- ``"none"`` (case-insensitive), which always maps to ``(0, 0, 0, 0)``.
324
+ If *alpha* is given, force the alpha value of the returned RGBA tuple
325
+ to *alpha*.
326
+
327
+ If None, the alpha value from *c* is used. If *c* does not have an
328
+ alpha channel, then alpha defaults to 1.
329
+
330
+ *alpha* is ignored for the color value ``"none"`` (case-insensitive),
331
+ which always maps to ``(0, 0, 0, 0)``.
332
+
315
333
If *alpha* is a sequence and *c* is a single color, *c* will be
316
334
repeated to match the length of *alpha*.
317
335
318
336
Returns
319
337
-------
320
338
array
321
- (n, 4) array of RGBA colors.
322
-
339
+ (n, 4) array of RGBA colors, where each channel (red, green, blue,
340
+ alpha) can assume values between 0 and 1.
323
341
"""
324
342
# Special-case inputs that are already arrays, for performance. (If the
325
343
# array has the wrong kind or shape, raise the error during one-at-a-time
0 commit comments