Function: makeSubplots()
function makeSubplots(options?): MakeSubplotsResult;Build a subplot grid like Python's make_subplots: axis domains, anchors and title annotations for rows × cols cells, and a place helper for traces.
Rows and columns are 1-based; row 1 is at the top (startCell: 'top-left', the default) or at the bottom ('bottom-left'). Axes are numbered in row-major order from row 1: each 'xy' cell gets the next xN/yN pair (a secondary y axis takes the next y id), with x anchored to its y and y to its x. specs can span cells (colspan, rowspan; the covered cells must be null), pad them (l, r, t, b), leave them empty (null) or make them 'domain' cells.
Cells of the same extent share one axis rather than Python's matches-linked axes: sharedX: true | 'columns' gives each column one x axis, drawn under its bottom-most subplot; sharedY: true | 'rows' gives each row one y axis, drawn left of its left-most subplot. Cells of different extents that share (sharedX: 'rows' / sharedY: 'columns', or 'all') get one axis per extent, linked with matches to the first (E3.9). A spanning cell in a shared column (row) keeps its own axis.
Parameters
| Parameter | Type |
|---|---|
options | MakeSubplotsOptions |
Returns
Example
const sp = makeSubplots({ rows: 2, cols: 2, sharedX: true, subplotTitles: ['A', 'B', 'C', 'D'] });
createChart(el, {
data: [
sp.place({ type: 'scatter', y: [1, 3, 2] }, 1, 1),
sp.place({ type: 'bar', y: [2, 1] }, 2, 2),
],
layout: { ...sp.layout, title: { text: 'Four panels' } },
});Throws
For invalid options (bad sizes, specs shape, overlapping spans, unknown or not yet supported subplot types, impossible sharing), with a message naming the problem.