Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 901761c

Browse files
authored
Merge pull request #9685 from anntzer/trivial-aliases
Trivial aliases.
2 parents 266062e + 0cb3b36 commit 901761c

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

lib/matplotlib/colors.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -251,21 +251,11 @@ def to_hex(c, keep_alpha=False):
251251

252252
### Backwards-compatible color-conversion API
253253

254+
254255
cnames = CSS4_COLORS
255256
hexColorPattern = re.compile(r"\A#[a-fA-F0-9]{6}\Z")
256-
257-
258-
def rgb2hex(c):
259-
'Given an rgb or rgba sequence of 0-1 floats, return the hex string'
260-
return to_hex(c)
261-
262-
263-
def hex2color(c):
264-
"""
265-
Take a hex string *s* and return the corresponding rgb 3-tuple
266-
Example: #efefef -> (0.93725, 0.93725, 0.93725)
267-
"""
268-
return ColorConverter.to_rgb(c)
257+
rgb2hex = to_hex
258+
hex2color = to_rgb
269259

270260

271261
class ColorConverter(object):
@@ -328,6 +318,7 @@ def to_rgba_array(arg, alpha=None):
328318

329319
colorConverter = ColorConverter()
330320

321+
331322
### End of backwards-compatible color-conversion API
332323

333324

0 commit comments

Comments
 (0)