Skip to content

region ​

Draws the cell it is in, such as the cell a partition gives each group. A region has no size or position of its own: on each axis where it is in a cell, it is that cell, placed by its data through the partition's scale, and on an axis where it is in no cell, it fills the space it is given. A region with an outline, such as a hexagon or a Voronoi cell of a partition over a binned struct, is drawn as that outline; any other region is drawn as a rectangle.

python
from gofish import Bin, Color, chart, field, partition, region

chart(movies, color=Color.gradient("blues"), axes=True).flow(
    partition(
        by={
            "x": field("IMDB Rating").bin(Bin.step(0.5)),
            "y": field("Rotten Tomatoes Rating").bin(Bin.step(5)),
        }
    )
).mark(region(fill=field("IMDB Rating").count())).render(w=480, h=320)

Signature ​

python
region(**options) -> Mark

Parameters ​

Draws the cell it is in, such as a partition's cell. It has no size or position of its own: on each axis where it is in a cell, it is that cell, placed by its data through the partition's scale, and on an axis where it is in no cell, it fills the space it is given. It draws the cell's outline when the cell has one (a hexagon of Bin.hex, a cell of Bin.voronoi), and a rectangle otherwise.

OptionTypeDefaultDescription
insetfloat0Pixels drawn in from each side of the cell it is in, on each axis where it is in a cell. Paint only: layout still reads the whole cell. A cell thinner than twice the inset draws nothing.
debugboolDev-only flag: logs this mark's key and datum to the console as it is built. It changes nothing about what is drawn.

Paint ​

OptionTypeDefaultDescription
fillstrFill color, or a field name for a color scale.
strokestrStroke color. Defaults to fill.
stroke_widthfloat0Stroke width in pixels.
opacityfloat1Opacity, 0 to 1.
filterstrRaw SVG filter attribute.

Returns a Mark for use in .mark().

Examples ​

python
# Outlined cells
.mark(region(fill="none", stroke="white", stroke_width=1))

# Cells drawn in by 2 pixels on each side, leaving a 4 pixel gap
.mark(region(fill="steelblue", inset=2))

See Underlying Space for how a partition gives each child its cell.