How to use the mapclassify.CLASSIFIERS function in mapclassify

To help you get started, we’ve selected a few mapclassify 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 ResidentMario / geoplot / geoplot / geoplot.py View on Github external
elif scheme is None:
            if norm is None:
                norm = mpl.colors.Normalize(vmin=hue.min(), vmax=hue.max())
            cmap = mpl.cm.ScalarMappable(norm=norm, cmap=cmap)
            colors = [cmap.to_rgba(v) for v in hue]
            categories = None
            self.k = None
        else:  # scheme is not None
            if isinstance(scheme, str):
                try:
                    if scheme == scheme.lower():
                        scheme = scheme.title()
                    
                    scheme = getattr(mc, scheme)(hue)
                except AttributeError:
                    opts = tuple(list(mc.CLASSIFIERS) + ['Categorical'])
                    raise ValueError(
                        f'Invalid scheme {scheme!r}. If specified as a string, scheme must be one '
                        f'of {opts}.'
                    )
            self.k = len(scheme.bins)

            if norm is None:
                norm = mpl.colors.Normalize(vmin=scheme.yb.min(), vmax=scheme.yb.max())
            cmap = mpl.cm.ScalarMappable(norm=norm, cmap=cmap)
            values = scheme(hue)
            binedges = [scheme.yb.min()] + scheme.bins.tolist()
            categories = [
                '{0:g} - {1:g}'.format(binedges[i], binedges[i + 1])
                for i in range(len(binedges) - 1)
            ]
            colors = [cmap.to_rgba(v) for v in values]

mapclassify

Classification Schemes for Choropleth Maps.

BSD-3-Clause
Latest version published 2 months ago

Package Health Score

79 / 100
Full package analysis

Similar packages