mark
Sets the visual mark drawn for each data item — the shape that turns rows into pixels.
python
from gofish import chart, spread, rect
chart(seafood).flow(spread(by="lake", dir="x")).mark(rect(h="count")).render(
w=500, h=300, axes=True
)Signature
python
ChartBuilder.mark(mark) -> ChartBuilderParameters
| Parameter | Type | Description |
|---|---|---|
mark | Mark | callable | A mark factory result, or a (data) -> ChartBuilder function |
Returns a new ChartBuilder with the mark set.
Mark types
| Mark | Draws |
|---|---|
| rect | A rectangle per item |
| circle | A circle per item |
| ellipse | An ellipse per item |
| line | A line through the items |
| area | A filled area through the items |
| blank | An invisible positioning guide |
Encoding channels
Mark options accept either a constant or a field name (a string matching a column in your data):
python
rect(h="count", fill="species") # height and color from data fields
rect(h="count", fill="#4e79a7") # height from data, constant colorNaming marks
Call .name("layerName") on a mark so another chart can reference it with select():
python
chart(data).flow(scatter(by="lake", x="x", y="y")).mark(blank().name("points"))The mark-as-function pattern
mark() also accepts a function (data) -> ChartBuilder. The function receives each group's data slice and returns a nested chart, letting you build custom glyphs:
python
chart(seafood).flow(spread(by="lake", dir="x")).mark(
lambda group: chart(group).flow(stack(by="species", dir="y")).mark(rect(h="count"))
)