MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / same_color

Function same_color

lib/matplotlib/colors.py:287–303  ·  view source on GitHub ↗

Return whether the colors *c1* and *c2* are the same. *c1*, *c2* can be single colors or lists/arrays of colors.

(c1, c2)

Source from the content-addressed store, hash-verified

285
286
287def same_color(c1, c2):
288 """
289 Return whether the colors *c1* and *c2* are the same.
290
291 *c1*, *c2* can be single colors or lists/arrays of colors.
292 """
293 c1 = to_rgba_array(c1)
294 c2 = to_rgba_array(c2)
295 n1 = max(c1.shape[0], 1) # 'none' results in shape (0, 4), but is 1-elem
296 n2 = max(c2.shape[0], 1) # 'none' results in shape (0, 4), but is 1-elem
297
298 if n1 != n2:
299 raise ValueError('Different number of elements passed.')
300 # The following shape test is needed to correctly handle comparisons with
301 # 'none', which results in a shape (0, 4) array and thus cannot be tested
302 # via value comparison.
303 return c1.shape == c2.shape and (c1 == c2).all()
304
305
306def to_rgba(c, alpha=None):

Calls 1

to_rgba_arrayFunction · 0.85

Used in the wild real call sites across dependent graphs

searching dependent graphs…