Customizing Size
At its core, a Vega-Lite specification describes a single plot. When a facet channel is added, the visualization is faceted into a trellis plot, which contains multiple sub-plots or cells.
Width and Height of a Single Plot
The width of a single plot or each cell of a trellis plot is determined by the properties of the x
channel:
- If the
x
channel has an ordinal scale, the width is a product of the scale’sbandSize
and the field’s cardinality, or number of possible distinct values of the field mapped to thex
channel, plus the scale’s padding. (bandWidth * (xCardinality + xPadding)). - If
x
has a continuous scale (either quantitative or time), the width is drawn directly from thewidth
property of the cell configuration. - If
x
is not mapped to a field, the width is derived from scale config’sbandSize
for all marks excepttext
and from scale config’stextBandWidth
fortext
mark.
Similarly, the height of a single plot or each cell of a trellis plot is determined by the properties of the y
channel:
- If the
y
channel has an ordinal scale, the height is a product of the scale’sbandSize
and the field’s cardinality, or number of possible distinct values of the field mapped to they
channel, plus the scale’s padding. (bandHeight * (yCardinality + yPadding)). - If
y
has a continuous scale (either quantitative or time), the height is drawn directly from theheight
property of the cell configuration. - If
y
is not mapped to a field, the height is derived from scale config’sbandSize
.
Total Width and Height of a Trellis Plots
The total width of the visualization is the product of the cell’s width plus the column
scale’s padding
and the cardinality of the column
((cellWidth + columnPadding) * columnCardinality).
Similarly, the total height of the visualization is the product of the cell’s height plus the row
scale’s padding
and the cardinality of the row
((cellHeight + rowPadding) * rowCardinality).