Source code for data_morph.shapes.points.dots_grid

"""Dots grid shape."""

import itertools

from ...data.dataset import Dataset
from ..bases.point_collection import PointCollection


[docs] class DotsGrid(PointCollection): """ Class representing a 3x3 grid of dots. .. plot:: :scale: 75 :caption: This shape is generated using the panda dataset. from data_morph.data.loader import DataLoader from data_morph.shapes.points import DotsGrid _ = DotsGrid(DataLoader.load_dataset('panda')).plot() Parameters ---------- dataset : Dataset The starting dataset to morph into other shapes. """ name = 'dots' def __init__(self, dataset: Dataset) -> None: xlow, xhigh = dataset.df.x.quantile([0.05, 0.95]).tolist() ylow, yhigh = dataset.df.y.quantile([0.05, 0.95]).tolist() xmid = (xhigh + xlow) / 2 ymid = (yhigh + ylow) / 2 super().__init__( *list(itertools.product([xlow, xmid, xhigh], [ylow, ymid, yhigh])) )