From 0cb3b3643a35f8c8cba598fd3995051ca523919e Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sat, 4 Nov 2017 11:15:12 -0700 Subject: [PATCH] Trivial aliases. colors.rgb2hex and colors.hex2color are trivial aliases of to_hex and to_rgb. --- lib/matplotlib/colors.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py index e57122150552..410eedfb6599 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -251,21 +251,11 @@ def to_hex(c, keep_alpha=False): ### Backwards-compatible color-conversion API + cnames = CSS4_COLORS hexColorPattern = re.compile(r"\A#[a-fA-F0-9]{6}\Z") - - -def rgb2hex(c): - 'Given an rgb or rgba sequence of 0-1 floats, return the hex string' - return to_hex(c) - - -def hex2color(c): - """ - Take a hex string *s* and return the corresponding rgb 3-tuple - Example: #efefef -> (0.93725, 0.93725, 0.93725) - """ - return ColorConverter.to_rgb(c) +rgb2hex = to_hex +hex2color = to_rgb class ColorConverter(object): @@ -328,6 +318,7 @@ def to_rgba_array(arg, alpha=None): colorConverter = ColorConverter() + ### End of backwards-compatible color-conversion API