package archimedes

  1. Overview
  2. Docs

A 2D plotting library with various backends.

  • version 0.4.19
  • author Christophe Troestler
  • author Pierre Hauweele
  • author Fabian Pijcke
  • author Noémie Meunier
  • author Bertrand Desmons

Introduction

module A = Archimedes
let vp = A.init ["graphic"; "hold"] in
A.Axes.box vp;
A.fx vp sin 0. 10.;
A.close vp

Affine transformations

module Matrix : sig ... end

Module implementing affine transformations and various operations on them.

module Color : sig ... end

Abstract representation of colors (suitable for RGBA).

module Path : sig ... end

Creating abstract paths.

module Backend : sig ... end

Module providing a uniform interface and managing the dynamic loading of the backends. This modules is only useful to create new backends and should not be used for plotting data.

module Coordinate : sig ... end

Systems of coordinates (inhomogeneous homotheties) relative to other coordinate systems with automatic updates. The automatic update refers to the fact that, if a coordinate system is upated, all coordinate systems which depend on it (possibly through several intermediate coordinate systems), they will use the updated version.

module Viewport : sig ... end

Area on which graphs can be made.

module Sampler : sig ... end

Adaptative sampling of functions.

module Marker : sig ... end

Module handling point styles and marks.

module Arrows : sig ... end

Arrow styles

module Tics : sig ... end

Tics position and labels.

module Axes : sig ... end

Routines to draw basic axes systems in a 2-dimensional space. One can either draw axes separately using add_(x|y)_axis or use a full default axes system with box or cross.

Initializing Archimedes

val init : ?lines:float -> ?text:float -> ?marks:float -> ?bg:Color.t -> ?w:float -> ?h:float -> ?dirs:string list -> string list -> Viewport.t

init backend initializes Archimedes and returns the main viewport using the backend specified. The first element of backend is the name (case insensitive) of the underlying engine. It may be followed by one or several options.

  • For the Graphics backend, "hold" will display the graphics window until you press a key. ["BMP"; filename] will save a copy of the display as a Windows Bitmap image file named filename.
  • For the Cairo backend, "Cairo"; "PNG"; filename uses a PNG surface to be saved to filename. You can replace "PNG" with "PDF", "PS" and "SVG".

The empty list selects "Graphics"; "hold".

  • parameter w

    the width of the main viewport (in backend's unit).

  • parameter h

    the height of the main viewport (in backend's unit).

  • parameter bg

    the color of the background. Default: Color.white.

  • parameter lines

    the width of the lines. Default: 1. which corresponds to a line width on the backend of min w h /. 500..

  • parameter text

    the size of the text. Default: 12. which corresponds to puting about 42 lines of text in min w h height.

  • parameter marks

    the size of the marks. Default: 7. which corresponds packing about 100 marks in min w h.

  • parameter dirs

    a list of directories where Archimedes looks for libraries (cma or cmxs) for dynamically loaded backends. The default is the directory where the backends that come with Archimedes were installed.

val backend_of_filename : string -> string list

Selects a backend according to the filename suffix. If the suffix is not matched (this in particular for ""), the graphics backend is selected.

val show : Viewport.t -> unit

Alias for Viewport.show.

val close : Viewport.t -> unit
val set_color : Viewport.t -> Color.t -> unit
val set_line_width : Viewport.t -> float -> unit
val xrange : Viewport.t -> float -> float -> unit

Alias for Viewport.xrange.

val yrange : Viewport.t -> float -> float -> unit

Alias for Viewport.yrange.

Plotting various datatypes

type style = [
  1. | `Lines
  2. | `Markers of string
  3. | `Linesmarkers of string
  4. | `Impulses
  5. | `Bars of float
  6. | `HBars of float
]

Style of various plots. Plotting functions only support the subset of these style that make sense for them.

  • `Lines Data points are joined by a simple line.
  • `Markers Data points are marked with the mark type given in argument of the Points constructor.
  • `Linesmarkers Data points are joined by a line and marked with the mark type given in argument.
  • `Impulses Data points are "hit" by lines starting from zero.
  • `Bars w Data points determine the height of a box of width w which must be given in Data coordinates (from 0 to 1).
  • `HBars h Data points determine the width of an horizontal box of height h which must be given in Data coordinates (from 0 to 1).

For the list of default marks for `Markers and `Linesmarkers have a look to Marker.names. You can also define your own with Marker.add.

val fx : Viewport.t -> ?tlog:bool -> ?fn0:float -> ?n:int -> ?strategy:Sampler.strategy -> ?cost:Sampler.cost -> ?style:[ `Lines | `Linesmarkers of string | `Markers of string ] -> ?base:(float -> float) -> ?fill:bool -> ?fillcolor:Color.t -> (float -> float) -> float -> float -> unit

Plotting functions.

fx vp f a b draws the graph of the function f on the interval [a, b].

  • parameter style

    the style of the plot. Default: `Lines.

  • parameter fill

    whether to fill the region between the graph of f and the base. Default: false.

  • parameter base

    the second function for delimiting the filling region. Default: the identically zero function.

  • parameter fn0

    the fraction of the maximum number of function evaluations used to create an initial sampling of the function that will later be refined by the adaptive autosampling. Default: 0.1.

  • parameter n

    the maximum number of function evaluations. Default: 100.

val xyf : Viewport.t -> ?tlog:bool -> ?fn0:float -> ?n:int -> ?strategy:Sampler.strategy -> ?cost:Sampler.cost -> ?style:[ `Lines | `Linesmarkers of string | `Markers of string ] -> ?fill:bool -> ?fillcolor:Color.t -> (float -> float * float) -> float -> float -> unit

xyf vp f a b draws the image of the function f on the interval [a, b], that is the set of points (x,y) = f(t) for t in [a,b].

The optional arguments are the same as for fx.

module Array : sig ... end

Plotting float Arrays.

module List : sig ... end

Plotting Lists of floats.

module Vec : sig ... end

Plotting Fortran bigarrays.

module CVec : sig ... end

Plotting C bigarrays.

Plotting generic data

val y : Viewport.t -> ?base:((float -> unit) -> unit) -> ?fill:bool -> ?fillcolor:Color.t -> ?style:style -> ((float -> unit) -> unit) -> unit

y vp iter draws on vp the values provided by the iterator iter. See Array.y for more information.

val xy : Viewport.t -> ?fill:bool -> ?fillcolor:Color.t -> ?style:[ `Lines | `Markers of string | `Linesmarkers of string ] -> ((float -> float -> unit) -> unit) -> unit

xy vp iter plots on vp the values provided by the iterator iter. See Array.xy for more information.

module Piechart : sig ... end