GnuplotEx.MultiPlot (gnuplot_ex v0.5.0)

Multi-panel plot composition using gnuplot's multiplot layout.

A %MultiPlot{} holds a list of %GnuplotEx.Plot{} panels rendered together in a single figure. Each panel retains its own series, title, and axis settings; the outer MultiPlot controls the terminal, output, overall grid layout, and optionally a shared x-axis.

Example

panel1 =
  GnuplotEx.new()
  |> GnuplotEx.title("Price")
  |> GnuplotEx.candlestick(ohlc_data)

panel2 =
  GnuplotEx.new()
  |> GnuplotEx.title("Volume")
  |> GnuplotEx.histogram(volume_data)

GnuplotEx.multiplot(layout: {2, 1}, shared_x: true, size: {800, 600})
|> GnuplotEx.add_panel(panel1)
|> GnuplotEx.add_panel(panel2)
|> GnuplotEx.to_png("/tmp/ohlc_stack.png")

Fields

  • :panels — list of %GnuplotEx.Plot{} structs (rendered in order)
  • :layout{rows, cols}; if nil, defaults to {length(panels), 1}
  • :shared_x — when true, a single x-range derived from the panels is emitted outside the multiplot block so every panel inherits it
  • :title — figure-level title emitted on set multiplot layout … title
  • :size{width, height} for the terminal
  • :terminal — output terminal (set by render/2,3 when called)
  • :output — output file path (set by to_svg/2, to_png/2, etc.)
  • :background — canvas color appended to the set terminal line (e.g. "#0e1116"). Only applied when :terminal is also set.
  • :commands — figure-level raw gnuplot commands emitted once between set output and set multiplot (grid, border, tics, key etc.)
  • :row_heights — list of ratios (summing to 1.0 ± 0.001) for unequal vertical panel heights. Mutually exclusive with :layout. When set, emits a bare set multiplot plus per-panel set size/set origin instead of set multiplot layout R,C.

Summary

Functions

Append a %Plot{} panel.

Append a figure-level raw command (emitted before set multiplot).

Set the layout {rows, cols}.

Build a new multiplot.

Toggle the shared x-axis mode.

Set the figure size {width, height}.

Set the figure-level title.

Types

layout()

@type layout() :: {pos_integer(), pos_integer()}

t()

@type t() :: %GnuplotEx.MultiPlot{
  background: String.t() | nil,
  commands: [list()],
  layout: layout() | nil,
  output: String.t() | nil,
  panels: [GnuplotEx.Plot.t()],
  row_heights: [number()] | nil,
  shared_x: boolean(),
  size: {pos_integer(), pos_integer()} | nil,
  terminal: atom() | nil,
  title: String.t() | nil
}

Functions

add_panel(mp, panel)

@spec add_panel(t(), GnuplotEx.Plot.t()) :: t()

Append a %Plot{} panel.

command(mp, cmd)

@spec command(t(), list()) :: t()

Append a figure-level raw command (emitted before set multiplot).

layout(mp, lt)

@spec layout(t(), layout()) :: t()

Set the layout {rows, cols}.

new(opts \\ [])

@spec new(keyword()) :: t()

Build a new multiplot.

Options

  • :layout{rows, cols}
  • :shared_x — boolean
  • :title — figure title
  • :size{width, height}
  • :background — canvas color (appended to set terminal line)
  • :commands — figure-level raw commands (list of command lists)
  • :row_heights — ratios for unequal panel heights (must sum to 1.0 ± 0.001)

shared_x(mp, flag)

@spec shared_x(t(), boolean()) :: t()

Toggle the shared x-axis mode.

size(mp, sz)

@spec size(
  t(),
  {pos_integer(), pos_integer()}
) :: t()

Set the figure size {width, height}.

title(mp, title_text)

@spec title(t(), String.t()) :: t()

Set the figure-level title.