Skip to content

Trivial aliases. #9685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 5, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions lib/matplotlib/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -328,6 +318,7 @@ def to_rgba_array(arg, alpha=None):

colorConverter = ColorConverter()


### End of backwards-compatible color-conversion API


Expand Down