Skip to content
Internals

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) -> ChartBuilder

Parameters

ParameterTypeDescription
markMark | callableA mark factory result, or a (data) -> ChartBuilder function

Returns a new ChartBuilder with the mark set.

Mark types

MarkDraws
rectA rectangle per item
circleA circle per item
ellipseAn ellipse per item
lineA line through the items
areaA filled area through the items
blankAn 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 color

Naming 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"))
)