Procs
proc createGrid(numPlots: int; numPlotsPerRow = 0; layout = Layout()): Grid {. ...raises: [], tags: [], forbids: [].}
- creates a Grid object with numPlots to which one can assign plots at runtime. Optionally the number of desired plots per row of the grid may be given. If left empty, the grid will attempt to produce a square, resorting to more columns than rows if not possible. Optionally a base layout can be given for the grid. Source Edit
proc createGrid(size: tuple[rows, cols: int]; layout = Layout()): Grid {. ...raises: [], tags: [], forbids: [].}
- creates a Grid object with rows x cols plots to which one can assign plots at runtime. Optionally a base layout can be given for the grid. Source Edit
proc toPlotJson(grid: Grid): PlotJson {....raises: [KeyError], tags: [], forbids: [].}
- converts the Grid object to a PlotJson object ready to be plotted via the normal show procedure. Source Edit
Macros
macro subplots(stmts: untyped): untyped
-
macro to create subplots from several Plot[T] objects the macro needs to contain the blocks baseLayout and one or more plot blocks. A plot block has the Plot[T] object in line 1, followed by the domain description of the subplot, i.e. the location within the whole canvas.
let plt1 = scatterPlot(x, y) # x, y some seqT let plt2 = scatterPlot(x2, y2) # x2, y2 some other seqT let layout = Layout(...) # some layout for the whole canvas let subplt = subplots: baseLayout: layout plot: plt1 left: 0.0 bottom: 0.0 width: 0.45 height: 1.0 # alternatively use right, top instead of width, height # single letters also supported, e.g. l == left plot: plt2 # or just write a concise tuple, here the (0.55, 0.0, 0.45, 1.0)
will create a subplot of plt1 on the left and plt2 on the right. This simply creates the following call to combine. let subplt = combine(layout, plt1.toPlotJson, plt2.toPlotJson, (left: 0.0, bottom: 0.0, width: 0.45, height: 1.0), (left: 0.55, bottom: 0.0, width: 0.45, height: 1.0))
Source Edit