Module Hugin.Figure

Module for figure-level operations (the top-level canvas).

type t

Abstract type representing a Figure, which contains Axes.

val create : ?width:int -> ?height:int -> unit -> t

create ?width ?height ()

Create a new figure canvas.

Parameters

  • ?width: figure width in pixels (default 800).
  • ?height: figure height in pixels (default 600).

Returns

  • a new Figure.t instance.

Examples

  let fig = create ~width:1024 ~height:768 () in
  ...
val add_axes : left:float -> bottom:float -> width:float -> height:float -> ?projection:Axes.projection -> t -> Axes.t

add_axes ~left ~bottom ~width ~height ?projection fig

Add custom-positioned axes to the figure.

Parameters

  • left: distance from left edge (0.0 to 1.0 fraction).
  • bottom: distance from bottom edge.
  • width: width of axes as fraction of figure.
  • height: height of axes as fraction of figure.
  • ?projection: TwoD or ThreeD (default TwoD).
  • fig: parent figure.

Returns

  • new Axes.t placed on the figure.

Examples

  let ax = add_axes ~left:0.1 ~bottom:0.1 ~width:0.8 ~height:0.8 fig in
  ...
val add_subplot : ?nrows:int -> ?ncols:int -> ?index:int -> ?projection:Axes.projection -> t -> Axes.t

add_subplot ?nrows ?ncols ?index ?projection fig

Add a subplot in a grid layout to the figure.

Parameters

  • ?nrows: number of rows in grid (default 1).
  • ?ncols: number of columns (default 1).
  • ?index: position index (1-based, default 1).
  • ?projection: TwoD or ThreeD axes type.
  • fig: parent figure.

Returns

  • new Axes.t for the subplot.

Examples

  let ax = add_subplot ~nrows:2 ~ncols:2 ~index:3 fig in
  ...
val clf : t -> t

clf fig

Clear all axes from the figure, resetting to empty canvas.

Parameters

  • fig: figure to clear.

Returns

  • cleared figure with no axes.

Examples

  let fig = clf fig in
  ...