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.
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
region(**options) -> MarkParameters
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.
| Option | Type | Default | Description |
|---|---|---|---|
inset | float | 0 | Pixels 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. |
debug | bool | Dev-only flag: logs this mark's key and datum to the console as it is built. It changes nothing about what is drawn. |
Paint
| Option | Type | Default | Description |
|---|---|---|---|
fill | str | Fill color, or a field name for a color scale. | |
stroke | str | Stroke color. Defaults to fill. | |
stroke_width | float | 0 | Stroke width in pixels. |
opacity | float | 1 | Opacity, 0 to 1. |
filter | str | Raw SVG filter attribute. |
Returns a Mark for use in .mark().
Examples
# 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.
