ontime.core.plotting.figure#

Figure, the subplot container of onTime.

A Plot is a single panel, made of layered marks. A Figure places several panels next to each other. Figures are built with the factories rows() and cols(), and they nest freely.

import ontime as on

on.rows(

on.Plot(solar).add(on.marks.line), on.Plot(nuclear).add(on.marks.line),

).properties(width=800, height=140).show()

Naming : rows(a, b) reads as “a and b are rows”, i.e. they are stacked vertically. The factories describe their arguments, not the container, which avoids the usual vstack / hstack ambiguity.

Scale sharing propagates : a share_x or share_y given explicitly to a group is inherited by its nested groups, unless the nested call sets the flag itself. A flag left unset nowhere in the chain falls back to the default of the group kind, i.e. share_x=True and share_y=False for rows, share_x=False and share_y=False for cols. This is the most likely source of surprise when nesting figures.

Placement : panels are measured with their axes and titles (bounds="full") and separated by spacing px, so they never run over each other. A shared axis is drawn only once, on the bottom row for x and on the leftmost column for y, and axis_extent px are reserved for every y axis so that the plotting areas stay aligned. All of this is tunable through Figure.properties().

Known constraint : in Vega-Lite 5, selection_interval(bind="scales") does not reliably propagate across concatenated views, therefore synchronised pan and zoom across panels is not supported. Sharing a scale domain (share_x / share_y) works, interactive linking does not.

Module Attributes

DEFAULT_BOUNDS

how the extent of a panel is measured when panels are concatenated, "full" counts the axes and the titles, "flush" only the plotting area

DEFAULT_AXIS_EXTENT

minimum room reserved for the y axis of a panel, in px, so that the plotting areas of stacked panels start at the same x position

Functions

cols(*panels[, share_x, share_y, sizes, ...])

Place panels side by side, i.e. the given panels are the columns.

rows(*panels[, share_x, share_y, sizes, ...])

Stack panels vertically, i.e. the given panels are the rows of the figure.

Classes

Figure(layout)

A composition of panels, compiled to concatenated Altair views.