def getcolor(spec):
    """
    Turn optional color string spec into an array.
    """
    if isinstance(spec, str):
        from matplotlib import colors
        return asarray(colors.hex2color(colors.cnames[spec]))
    else:
        return spec
def getcolor ( spec ) : if isinstance ( spec , str ) : from matplotlib import colors return asarray ( colors . hex2color ( colors . cnames [ spec ] ) ) else : return spec
Turn optional color string spec into an array.