package plplot

  1. Overview
  2. Docs

Module Plplot.PlotSource

A higher-level OCaml interface to PLplot

THIS API IS NOT FIXED AND MAY CHANGE BEFORE THE 5.10.0 RELEASE

Sourcetype side_t = [
  1. | `top
  2. | `bottom
  3. | `left
  4. | `right
]
Sourcetype 'a tagged_side_t = [
  1. | `top of 'a
  2. | `bottom of 'a
  3. | `left of 'a
  4. | `right of 'a
]

The different sides of a (2D) plot. These values are used to represent, e.g., offsets along axes and text placement.

Sourcetype axis_options_t = [
  1. | `axis
  2. | `frame0
  3. | `frame1
  4. | `time
  5. | `fixed_point
  6. | `major_grid
  7. | `minor_grid
  8. | `invert_ticks
  9. | `log
  10. | `unconventional_label
  11. | `label
  12. | `custom_label
  13. | `minor_ticks
  14. | `minor_tick_count of int
  15. | `major_ticks
  16. | `major_tick_spacing of float
  17. | `vertical_label
]

These are the available options for drawing plot axes. These values map to individual letters provided to Plplot.plbox and similar functions.

Sourcetype stream_t

A plot stream.

Sourcetype color_t = [
  1. | `white
  2. | `red
  3. | `yellow
  4. | `green
  5. | `gray
  6. | `blue
  7. | `light_blue
  8. | `purple
  9. | `pink
  10. | `black
  11. | `brown
  12. | `index of int
]

Colors from the indexed color map (color map 0), from the cmapo_alternate.pal file! Note that these will NOT match up with colors from the default color palette!

Sourcetype map_t = [
  1. | `globe
  2. | `usa
  3. | `countries
  4. | `all
]

Different map outlines available for map

Sourcetype pltr_t = float -> float -> float * float

Type signature for coordinate transform functions

Sourcetype plot_t

A plottable element, usable by the function plot.

Sourcetype plot_device_family_t = [
  1. | `cairo
  2. | `qt
  3. | `core
  4. | `wx
]

The different available plot device families. This is not a complete representation of all of the available devices provided by PLplot.

Sourcetype plot_device_t = [
  1. | `pdf of plot_device_family_t
  2. | `png of plot_device_family_t
  3. | `ps of plot_device_family_t
  4. | `svg of plot_device_family_t
  5. | `window of plot_device_family_t
  6. | `prompt
    (*

    Ask for the correct device to use at run-time

    *)
  7. | `stream of int
    (*

    Pre-defined plot streams

    *)
  8. | `other_device of string
]

Plot devices. The constructor argument allows one to define which device family is used.

PLplot plotting devices otherwise not available from this list

Sourcetype plot_scaling_t = [
  1. | `preset
  2. | `greedy
  3. | `equal
  4. | `equal_square
]

Type of scaling to use for plot axes, as in Plplot.plenv.

Sourcetype color_palette_t

A color palette, usually loaded from disk

Sourcetype line_style_t = [
  1. | `solid
  2. | `line1
  3. | `line2
  4. | `line3
  5. | `line4
  6. | `line5
  7. | `line6
  8. | `line7
  9. | `line8
    (*

    These correspond to PLplot's pre-defined line styles as set by pllsty.

    *)
  10. | `custom of (int * int) list
]

Line plotting styles/patterns.

A custom line style, with each (mark, space) pair defining the length of one segment and gap in the line drawing pattern.

Sourceval default_axis_options : axis_options_t list

The default list of axis rendering options, used for all plots generated with init if no custom options are provided.

Sourceval rgb_of_color : color_t -> int * int * int

Convert color_t values to r, g, b integer values, each ranging in value from 0 - 255.

A recommended/standard file name extension, given a particular plot device.

Plot streams
Sourceval make_stream : ?stream:int -> unit -> stream_t

Make a new stream_t, possibly using an existing plot stream index. If no stream argument is provided then a new plot stream is created.

Sourceval start_page : ?stream:stream_t -> (float * float) -> (float * float) -> plot_scaling_t -> unit

start_page ?stream (x0, y0) (x1, y1) scaling starts a new plot page with the given dimensions and scaling.

Sourceval next_page : ?stream:stream_t -> (float * float) -> (float * float) -> plot_scaling_t -> unit

An alias for start_page.

Sourceval make : ?stream:stream_t -> ?filename:string -> ?size:(int * int) -> ?pre:(unit -> unit) -> plot_device_t -> stream_t

Create a new plot instance. See init for a description of the parameters.

Sourceval init : ?filename:string -> ?size:(int * int) -> ?pages:(int * int) -> ?pre:(unit -> unit) -> (float * float) -> (float * float) -> plot_scaling_t -> plot_device_t -> stream_t

init ?filename ?size ?pages (x0, y0) (x1, y1) scale device - Start a new plot stream for a 2D plot with plot axis extents given by (x0, y0) to (x1, y1). A call to init is roughly equivalent to calling make and then start_page.

  • parameter filename

    Plot output filename. A suitable file extension will be added if it does not already exist.

  • parameter size

    Dimension of the plot in physical units (e.g., pixels for bitmap outputs (PNG, X) and 1/72 inch for vector outputs (PS, PDF, SVG)

  • parameter pages

    Layout of multiple plots on a single page

  • parameter pre

    This function, if provided, is called just before the plot instance is initialized. It can be used to, for example, load custom color palettes.

Sourceval with_stream : ?stream:stream_t -> (unit -> 'a) -> 'a

with_stream ?stream f performs f with stream as the active plot stream. If stream is not provided then the currently active plot stream is left active. Once f is complete, the previously active plot stream is restored.

Sourceval make_stream_active : stream:stream_t -> unit

make_stream_active stream makes stream in to the currently active plot stream for The standard PLplot API calls or any function which is not provided with an explicit stream argument.

Colors
Sourceval set_color : ?stream:stream_t -> color_t -> unit

set_color ?stream color sets the current active plot color to color.

Sourceval set_color_scale : ?stream:stream_t -> ?pos:float array -> ?alt_hue_path:bool array -> color_t array -> unit

set_color_scale ?stream ?pos ?alt_hue_path colors sets the continuous color map (color map 1) to a scale determined by interpolating between colors. pos can be used to specify where in the color scale (0.0 - 1.0) the a color interpolation point should fall. pos defaults to even spacing. alt_hue_path can be used to specify that a given segment should be interpolated using the alternative hue path which always includes the hue=0 point. Plplot.plscmap1l is used internally to set the color scale.

Sourceval indexed_palette : string -> color_palette_t

PLplot has two color palettes - indexed (color map 0) and continuous (color map 1). These functions can be used with load_palette to set custom indexed and continuous color palettes.

Sourceval continuous_palette : ?interpolate:bool -> string -> color_palette_t

continuous_palette ?interpolate filename - If interpolate is true (the default) then a smooth palette is generated using the color definitions in the palette file filename. Otherwise, the colors are considered to be discrete, giving a segmented palette.

Sourceval load_palette : ?stream:stream_t -> color_palette_t -> unit

load_palette ?stream palette loads either indexed or continuous color palette information from a file on disk.

Plot elements
Sourceval arc : ?fill:bool -> color_t -> float -> float -> float -> float -> float -> float -> float -> plot_t

arc ?fill color x y a b angle0 angle1 rotate

Sourceval axes : ?color:color_t -> ?style:line_style_t -> ?width:float -> ?labelfunc:([ `x | `y | `z ] -> float -> string) -> axis_options_t list -> axis_options_t list -> plot_t

axes ?color ?style ?width xopt yopt

Sourceval default_axes : plot_t

default_axes is equivalent to axes default_axis_options default_axis_options

Sourceval circle : ?fill:bool -> color_t -> float -> float -> float -> plot_t

circle ?fill color x y r

Sourceval contours : color_t -> pltr_t -> float array -> float array array -> plot_t

contours color tranform_func contours data

Sourceval image : ?range:(float * float) -> (float * float) -> (float * float) -> float array array -> plot_t

image ?range (x0, y0) (x1, y1) data

Sourceval imagefr : ?range:(float * float) -> scale:(float * float) -> (float * float) -> (float * float) -> float array array -> plot_t

imagefr ?range ~scale (x0, y0) (x1, y1) data

Sourceval join : ?style:line_style_t -> ?width:float -> color_t -> (float * float) -> (float * float) -> plot_t

join ?style color (x0, y0) (x1, y1)

Sourceval label : ?color:color_t -> string -> string -> string -> plot_t

label ?color x_label y_label title adds axis labels and a title.

Sourceval lines : ?label:string -> ?style:line_style_t -> ?width:float -> color_t -> float array -> float array -> plot_t

lines ?label ?style color xs ys

Sourceval map : ?sw:(float * float) -> ?ne:(float * float) -> color_t -> map_t -> plot_t

map ?sw ?ne color outline_type

Sourceval points : ?label:string -> ?symbol:string -> ?scale:float -> color_t -> float array -> float array -> plot_t

points ?label ?symbol ?scale color xs ys

Sourceval polygon : ?fill:bool -> color_t -> float array -> float array -> plot_t

polygon ?fill color xs ys

Sourceval rectangle : ?fill:bool -> color_t -> (float * float) -> (float * float) -> plot_t

rectangle ?fill color (x0, y0) (x1, y1)

Sourceval shades : ?fill_width:float -> ?contour:(color_t * float) -> ?rect:bool -> (float * float) -> (float * float) -> float array -> float array array -> plot_t

shades ?fill_width ?contour ?rect (x0, y0) (x1, y1) contours data

Sourceval text : ?dx:float -> ?dy:float -> ?just:float -> color_t -> float -> float -> string -> plot_t

text ?dx ?dy ?just color x y string writes the text string inside the plot window, at an optional angle defined by the offsets dx and dy.

Sourceval text_outside : ?just:float -> ?perp:bool -> color_t -> float tagged_side_t -> float -> string -> plot_t

text_outside ?just ?perp color side offset string writes text outside of the plot window, along side, displaced from the axis by offset * character height.

Sourceval func : ?symbol:string -> ?step:float -> color_t -> (float -> float) -> (float * float) -> plot_t

func ?symbol ?step color f (min, max) plots the function f from x = min to x = max. step can be used to tighten or coarsen the sampling of plot points.

Sourceval transform : pltr_t -> plot_t

transform f sets the universal coordinate transformation function.

Sourceval clear_transform : plot_t

clear_transform clears any currently defined universal coordinate transform function.

Sourceval pltr : pltr_t -> plot_t

pltr f sets the coordinate transformation function used by imagefr and other functions affected by Plplot.plset_pltr.

Sourceval clear_pltr : plot_t

clear_pltr clears any currently defined function-specific pltr transform function.

Sourceval custom : (unit -> unit) -> plot_t

custom f will call f () when the plot element is used. This function can be used to create customized plot elements for use with plot.

Sourceval list : plot_t list -> plot_t

list l makes a plot element from a list of plot elements, allowing, for example, a plot to be created piece-by-piece before being rendered.

Sourceval maybe : plot_t option -> plot_t

maybe m_p will plot the contents of m_p. If m_p is None then this is effectively a no-op.

Sourceval plot : ?stream:stream_t -> plot_t list -> unit

Plot a list of plottable elements

Support functions
Sourceval character_height : ?stream:stream_t -> unit -> float

Character height in world coordinate units

Sourcetype position_t

Positioning within viewport or subpage

Sourceval viewport_pos : ?side1:side_t -> ?side2:side_t -> ?inside:bool -> float -> float -> position_t

Position relative to the plot viewport

Sourceval subpage_pos : ?side1:side_t -> ?side2:side_t -> ?inside:bool -> float -> float -> position_t

Position relative to the plot subpage

Sourcetype legend_entry_t

Legend entry

Sourcetype 'a layout_t

Layout of elements

Sourceval no_legend : legend_entry_t

Empty legend entry

Sourceval box_legend : ?pattern:int -> ?scale:float -> ?line_width:float -> ?label_color:color_t -> label:string -> color_t -> legend_entry_t

Color-filled box legend entry

Sourceval line_legend : ?style:int -> ?width:float -> ?label_color:color_t -> label:string -> color_t -> legend_entry_t

Line legend entry

Sourceval symbol_legend : ?scale:float -> ?number:int -> ?label_color:color_t -> label:string -> color_t -> string -> legend_entry_t

Symbol/point legend entry

Sourceval row_major : 'a -> 'b -> ('a * 'b) layout_t

Row-major layout

Sourceval column_major : 'a -> 'b -> ('a * 'b) layout_t

Column-major layout

Sourceval legend : ?pos:position_t -> ?plot_width:float -> ?bg:color_t -> ?bb:(color_t * line_style_t) -> ?layout:(int * int) layout_t -> ?color:color_t -> ?text_offset:float -> ?text_scale:float -> ?text_spacing:float -> ?text_justification:float -> ?text_left:bool -> legend_entry_t list list -> plot_t

legend entries

Sourcetype colorbar_axis_t

Colorbar axis definitions

Sourcetype colorbar_kind_t

Available colorbar kinds

Sourceval colorbar_axis : ?axis:axis_options_t list -> float array -> colorbar_axis_t

colorbar_axis ?axis values creates a colorbar_axis_t with the given axis options and range values.

Sourceval gradient_colorbar : ?axis:axis_options_t list -> float array -> colorbar_kind_t

gradient_colorbar ?axis [|min; max|] from min to max

Sourceval image_colorbar : ?axis:axis_options_t list -> float array -> colorbar_kind_t

image_colorbar ?axis [|min; max|] from min to max

Sourceval shade_colorbar : ?custom:bool -> ?axis:axis_options_t list -> float array -> colorbar_kind_t

shade_colorbar ?custom ?axis contours defines a shaded contour colorbar with axis labels at even spacings (custom = false) or at the locations of the values in contours (custom = true - the default).

Sourceval default_colorbar_axis : axis_options_t list

Default options used for a colorbar axis

Sourceval colorbar : ?pos:position_t -> ?bg:color_t -> ?bb:(color_t * line_style_t) -> ?cap:(float option * float option) -> ?contour:(color_t * float) -> ?orient:(float * float) tagged_side_t -> ?axis:colorbar_axis_t list -> ?label:string tagged_side_t list -> ?color:color_t -> ?scale:float -> colorbar_kind_t -> plot_t

colorbar colorbar_kind

Sourceval plot_axes : ?stream:stream_t -> axis_options_t list -> axis_options_t list -> unit

Draw the plot axes on the current plot page

Finishing up a plot page
Sourceval end_stream : ?stream:stream_t -> unit -> unit

end_stream ?stream () ends stream. This or finish should be called once all plotting is complete.

Sourceval finish : ?stream:stream_t -> unit -> unit

finish ?stream () draws default x and y axes, then closes stream.