flow
Applies a pipeline of operators to the chart's data. Operators partition, position, and transform the data before the mark draws it.
python
from gofish import chart, spread, stack, rect
chart(seafood).flow(
spread(by="lake", dir="x"),
stack(by="species", dir="y", label=False),
).mark(rect(h="count", fill="species")).render(w=500, h=300, axes=True)Signature
python
ChartBuilder.flow(*operators) -> ChartBuilderParameters
| Parameter | Type | Description |
|---|---|---|
*operators | Operator | One or more operators, applied left to right |
Returns a new ChartBuilder with the operators appended.
How it works
Operators run in order. Each one receives the data (or groups) produced by the previous one. In the example above:
spread(by="lake", dir="x")splits the rows into one group per lake and places the groups across the x axis.stack(by="species", dir="y")stacks each lake's rows by species along y.
The mark then draws every leaf row.
Available operators
| Operator | Purpose |
|---|---|
| spread | Lay groups out along an axis, with gaps |
| stack | Stack groups edge-to-edge along an axis |
| table | Lay groups out in a 2D grid |
| scatter | Position groups by x/y fields |
| group | Wrap each partition in a frame |
| derive | Transform the data with a Python function |
| log | Print the data for debugging |
Notes
flow()can be called multiple times; operators accumulate.- A chart with no
flow()draws a single mark over the whole dataset.
