Skip to content

render ​

Renders the chart as an anywidget that displays in Jupyter, JupyterLab, VS Code notebooks, and marimo.

python
from gofish import chart, spread, rect

chart(seafood, axes=True).flow(spread(by="lake", dir="x")).mark(
    rect(h="count")
).render(w=500, h=300)

Signature ​

python
ChartBuilder.render(w=800, h=600, axes=None, legend=None, padding=None, debug=False)

layer(...) and .layer(...) chains (LayerBuilder) and bare marks take the same options. They are the JS .render(container, options) options, in snake case.

Parameters ​

ParameterTypeDefaultDescription
wint800Width in pixels
hint600Height in pixels
axesbool | dict | NoneNoneAuto-generate axes, labels, and legends; same shape as chart(axes=...). Unset, the chart's own axes option decides.
legendbool | NoneNoneWhether to draw the color-scale legend. Unset, the default (True) applies. A chart() option of the same name wins over this one.
paddingfloat | NoneNoneExtra pixels between the drawing and the SVG edge. Unset, the chart's own padding option (or the default) applies.
debugboolFalseWhether to enable debug rendering

Returns a GoFishChartWidget.

Axes on the chart or on render

axes (and padding) can be passed to chart or to render, as in JS (chart(data, { axes: true }) or .render(container, { axes: true })). See chart for the full axes shape.

Automatic display ​

A ChartBuilder displays itself when it is the last expression in a notebook cell — no .render() call is required:

python
chart(seafood).flow(spread(by="lake", dir="x")).mark(rect(h="count"))

This is equivalent to calling .render() with its defaults. Call .render() explicitly when you want to set the size or other render options:

python
chart(seafood, axes=True).flow(spread(by="lake", dir="x")).mark(
    rect(h="count")
).render(w=500, h=300)

Inspecting the IR ​

.to_ir() returns the chart's JSON intermediate representation instead of rendering — useful for debugging or testing:

python
chart(seafood).flow(spread(by="lake", dir="x")).mark(rect(h="count")).to_ir()

Notes ​

  • Rendering requires a notebook kernel — render() produces a widget. To get an SVG file or string, use save / to_svg.
  • A chart must have a mark before it can be rendered.