How to use the geoplot.geoplot.HueMixin function in geoplot

To help you get started, we’ve selected a few geoplot 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 / tests / View on Github external
def create_huemixin():
            huemixin = HueMixin()
            # set props the mixin is responsible for
            huemixin.kwargs = {'hue': 'foo', 'cmap': 'viridis', 'norm': None}
            # set props set by the plot object initializer
   = None
            huemixin.figsize = (8, 6)
            huemixin.extent = None
            huemixin.projection = None

            huemixin.df = gpd.GeoDataFrame(
                {'foo': np.random.random(100), 'geometry': utils.gaussian_points(n=100)}
            return huemixin
github ResidentMario / geoplot / geoplot / View on Github external
nmin = nmin if nmin else np.max([1, np.round(len(df) / 100)]).astype(int)

        # Jitter the points. Otherwise if there are n points sharing the same coordinate, but
        # n_sig < n, the quadtree algorithm will recurse infinitely. Jitter is applied randomly
        # on 10**-5 scale, inducing maximum additive inaccuracy of ~1cm - good enough for the
        # vast majority of geospatial applications. If the meaningful precision of your dataset
        # exceeds 1cm, jitter the points yourself. cf.
        df = df.assign(geometry=jitter_points(df.geometry))

        # Generate a quadtree.
        quad = QuadTree(df)
        partitions = quad.partition(nmin, nmax)
        self.partitions = list(partitions)

class QuadtreeHueMixin(HueMixin):
    Subclass of HueMixin that provides modified hue-setting code for the quadtree plot.
    def set_hue_values(self, color_kwarg, default_color):
        agg = self.kwargs.pop('agg')
        nsig = self.kwargs.pop('nsig')
        _df = self.df
        dvals = []

        # If no hue is set, getting the correct (null) colormap values is as easy as calling
        # the same set_hue_values used by most other plots.
        # If hue *is* set, things are more complicated. The quadtree colormap is applied to a map
        # over self.partitions, but set_hue_values is called on self.df. So we temporarily swap
        # self.df out for the map on self.partitions, run set_hue_values, then swap the original
        # GeoDataFrame back into place. We apply the nsig adjustment afterwards.