convert continuous values into colors using matplotlib colorscales
        :param value: value to be converted
        :param maxvalue: max value in the colorscale
        :param scale: lin, log, sqrt
        :param minvalue: minimum of the input values in linear scale (default is 0)
        :return: the color corresponding to the value

def to_color(self, value, maxvalue, scale, minvalue=0.0):
        """
        convert continuous values into colors using matplotlib colorscales
        :param value: value to be converted
        :param maxvalue: max value in the colorscale
        :param scale: lin, log, sqrt
        :param minvalue: minimum of the input values in linear scale (default is 0)
        :return: the color corresponding to the value
        """
        
        if scale == 'lin':
            if minvalue >= maxvalue:
                raise Exception('minvalue must be less than maxvalue')
            else:
                value = 1.*(value-minvalue) / (maxvalue-minvalue)
        elif scale == 'log':
            if value < 1 or maxvalue <= 1:
                raise Exception('value and maxvalue must be >= 1')
            else:
                value = math.log(value) / math.log(maxvalue)
        elif scale == 'sqrt':
            if value < 0 or maxvalue <= 0:
                raise Exception('value and maxvalue must be greater than 0')
            else:
                value = math.sqrt(value) / math.sqrt(maxvalue)
        else:
            raise Exception('scale must be "lin", "log", or "sqrt"')

        if value < 0:
            value = 0
        elif value > 1:
            value = 1

        value = int(1.*self.levels*value)*1./(self.levels-1)

        if value not in self.mapping:
            self.mapping[value] = _convert_color_format(self.cmap(value), self.alpha)
        return self.mapping[value]