Module Hugin.Axes

Module for axes-level operations (the plotting area).

type t

Abstract type representing an Axes object within a figure.

type projection =
  1. | TwoD
  2. | ThreeD

Type representing the projection of the axes.

type scale =
  1. | Linear
  2. | Log

Type representing axis scale.

val set_title : string -> t -> t

set_title title axes

Set the title text for the axes.

Parameters

  • title: string to display as the axes title.
  • axes: axes instance to modify.

Returns

  • updated axes with the new title.

Examples

  let ax = set_title "My Plot" ax in
  ...
val set_xlabel : string -> t -> t

set_xlabel label axes

Set the x-axis label text for the axes.

Parameters

  • label: string to display on the x-axis.
  • axes: axes instance to modify.

Returns

  • updated axes with the new x-axis label.

Examples

  let ax = set_xlabel "Time (s)" ax in
  ...
val set_ylabel : string -> t -> t

set_ylabel label axes

Set the y-axis label text for the axes.

Parameters

  • label: string to display on the y-axis.
  • axes: axes instance to modify.

Returns

  • updated axes with the new y-axis label.

Examples

  let ax = set_ylabel "Amplitude" ax in
  ...
val set_zlabel : string -> t -> t

set_zlabel label axes

Set the z-axis label text for 3D axes.

Parameters

  • label: string to display on the z-axis.
  • axes: 3D axes instance to modify.

Returns

  • updated axes with the new z-axis label.

Examples

  let ax3d = set_zlabel "Depth" ax3d in
  ...
val set_xlim : ?min:float -> ?max:float -> t -> t

set_xlim ?min ?max axes

Set the visible range for the x-axis.

Parameters

  • ?min: lower x-axis limit; Float.nan for automatic.
  • ?max: upper x-axis limit; Float.nan for automatic.
  • axes: axes instance to modify.

Returns

  • updated axes with specified x-axis limits.

Examples

  let ax = set_xlim ~min:0. ~max:10. ax in
  ...
val set_ylim : ?min:float -> ?max:float -> t -> t

set_ylim ?min ?max axes

Set the visible range for the y-axis.

Parameters

  • ?min: lower y-axis limit; Float.nan for automatic.
  • ?max: upper y-axis limit; Float.nan for automatic.
  • axes: axes instance to modify.

Returns

  • updated axes with specified y-axis limits.

Examples

  let ax = set_ylim ~min:-1. ~max:1. ax in
  ...
val set_zlim : ?min:float -> ?max:float -> t -> t

set_zlim ?min ?max axes

Set the visible range for the z-axis in 3D plots.

Parameters

  • ?min: lower z-axis limit; Float.nan for automatic.
  • ?max: upper z-axis limit; Float.nan for automatic.
  • axes: 3D axes instance to modify.

Returns

  • updated axes with specified z-axis limits.

Examples

  let ax3d = set_zlim ~min:0. ~max:5. ax3d in
  ...
val set_xscale : scale -> t -> t

set_xscale scale axes

Set the x-axis scaling (linear or logarithmic).

Parameters

  • scale: Linear or Log.
  • axes: axes instance to modify.

Returns

  • updated axes with new x-axis scale.

Examples

  let ax = set_xscale Log ax in
  ...
val set_yscale : scale -> t -> t

set_yscale scale axes

Set the y-axis scaling (linear or logarithmic).

Parameters

  • scale: Linear or Log.
  • axes: axes instance to modify.

Returns

  • updated axes with new y-axis scale.

Examples

  let ax = set_yscale Log ax in
  ...
val set_xticks : float list -> t -> t

set_xticks ticks axes

Set manual tick positions on the x-axis.

Parameters

  • ticks: list of positions (floats).
  • axes: axes instance to modify.

Returns

  • updated axes with specified x-axis ticks.

Examples

  let ax = set_xticks [0.;1.;2.;3.] ax in
  ...
val set_yticks : float list -> t -> t

set_yticks ticks axes

Set manual tick positions on the y-axis.

Parameters

  • ticks: list of positions.
  • axes: axes instance.

Returns

  • updated axes with specified y-axis ticks.

Examples

  let ax = set_yticks [0.;0.5;1.] ax in
  ...
val set_zticks : float list -> t -> t

set_zticks ticks axes

Set manual tick positions on the z-axis (3D plots).

Parameters

  • ticks: list of positions.
  • axes: 3D axes instance.

Returns

  • updated axes with specified z-axis ticks.

Examples

  let ax3d = set_zticks [0.;5.;10.] ax3d in
  ...
val set_elev : float -> t -> t

set_elev angle axes

Set elevation angle for 3D axes in degrees.

Parameters

  • angle: elevation angle in degrees.
  • axes: 3D axes instance.

Returns

  • updated axes with new elevation.

Examples

  let ax3d = set_elev 30. ax3d in
  ...
val set_azim : float -> t -> t

set_azim angle axes

Set azimuth angle for 3D axes in degrees.

Parameters

  • angle: azimuth angle in degrees.
  • axes: 3D axes instance.

Returns

  • updated axes with new azimuth.

Examples

  let ax3d = set_azim 45. ax3d in
  ...
val grid : ?which:[ `major | `minor | `both ] -> ?axis:[ `x | `y | `both ] -> bool -> t -> t

grid ?which ?axis visible axes

Toggle grid lines on the axes.

Parameters

  • ?which: `major , `minor , or `both grid lines.
  • ?axis: axes to apply ( `x , `y , or `both ).
  • visible: true to show, false to hide.
  • axes: axes instance.

Returns

  • updated axes with grid state changed.

Notes

  • Defaults: which=`major, axis=`both.

Examples

  let ax = grid ~visible:true axes in
  ...
val add_artist : Artist.t -> t -> t

add_artist artist axes

Add a custom artist to the axes.

Parameters

  • artist: an Artist.t element.
  • axes: axes instance to draw onto.

Returns

  • updated axes with the artist added.

Examples

  let a = Artist.line2d x_arr y_arr in
  let ax = add_artist a ax in
  ...
val cla : t -> t

cla axes

Clear all artists, titles, and labels from the axes.

Parameters

  • axes: axes instance to clear.

Returns

  • cleared axes ready for fresh plotting.

Examples

  let ax = cla ax in
  ...
type legend_loc =
  1. | Best
  2. | UpperRight
  3. | UpperLeft
  4. | LowerLeft
  5. | LowerRight
  6. | Right
  7. | CenterLeft
  8. | CenterRight
  9. | LowerCenter
  10. | UpperCenter
  11. | Center

Legend location options

val legend : ?loc:legend_loc -> ?ncol:int -> bool -> t -> t

legend ?loc ?ncol visible axes

Show or hide legend for labeled artists.

Parameters

  • ?loc: legend location (default Best).
  • ?ncol: number of columns (default 1).
  • visible: true to show, false to hide.
  • axes: axes instance.

Returns

  • updated axes with legend settings.

Examples

  let ax = legend ~loc:UpperRight true ax in
  ...