How to use the branca.colormap.ColorMap function in branca

To help you get started, we’ve selected a few branca examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-visualization / branca / branca / colormap.py View on Github external
return StepColormap(colors, index=index, vmin=index[0], vmax=index[-1])

    def scale(self, vmin=0., vmax=1.):
        """Transforms the colorscale so that the minimal and maximal values
        fit the given parameters.
        """
        return LinearColormap(
            self.colors,
            index=[vmin + (vmax-vmin)*(x-self.vmin)*1./(self.vmax-self.vmin) for x in self.index],  # noqa
            vmin=vmin,
            vmax=vmax,
            caption=self.caption,
            )


class StepColormap(ColorMap):
    """Creates a ColorMap based on linear interpolation of a set of colors
    over a given index.

    Parameters
    ----------
    colors : list-like object
        The set of colors to be used for interpolation.
        Colors can be provided in the form:
        * tuples of int between 0 and 255 (e.g: `(255,255,0)` or
        `(255, 255, 0, 255)`)
        * tuples of floats between 0. and 1. (e.g: `(1.,1.,0.)` or
        `(1., 1., 0., 1.)`)
        * HTML-like string (e.g: `"#ffff00`)
        * a color name or shortcut (e.g: `"y"` or `"yellow"`)
    index : list of floats, default None
        The values corresponding to each color.
github jupyter-widgets / ipyleaflet / ipyleaflet / leaflet.py View on Github external
    @observe('geo_dataframe')
    def _update_data(self, change):
        self.data = self._get_data()

    def _get_data(self):
        return json.loads(self.geo_dataframe.to_json())


class Choropleth(GeoJSON):

    geo_data = Dict()
    choro_data = Dict()
    value_min = Float(None, allow_none=True)
    value_max = Float(None, allow_none=True)
    colormap = Instance(ColorMap)
    border_color = Color('black')

    @observe('choro_data')
    def _update_bounds(self, change):
        self.value_min = min(self.choro_data.items(), key=lambda x: x[1])[1]
        self.value_max = max(self.choro_data.items(), key=lambda x: x[1])[1]

    @observe('value_min', 'value_max', 'geo_data', 'choro_data', 'colormap', 'border_color')
    def _update_data(self, change):
        self.data = self._get_data()

    @default('colormap')
    def _default_colormap(self):
        return linear.OrRd_06

    def _get_data(self):
github python-visualization / branca / branca / colormap.py View on Github external
def __init__(self, vmin=0., vmax=1., caption=''):
        super(ColorMap, self).__init__()
        self._name = 'ColorMap'

        self.vmin = vmin
        self.vmax = vmax
        self.caption = caption
        self.index = [vmin, vmax]