module Plot: sig
.. end
Libplot bindings
Datatypes
The plotter
abstract type implements the plotter object used
by every drawing function in the library. It is created using function
Plot.makepl
. At creation, a plotter_format
value must
be specified : it is the output format of the plotter. All of
libplot
's formats are supported.
type
plotter
type
plotter_format =
| |
X |
| |
PNG |
| |
PNM |
| |
GIF |
| |
SVG |
| |
AI |
| |
PS |
| |
CGM |
| |
FIG |
| |
PCL |
| |
HPGL |
| |
REGIS |
| |
TEK |
| |
META |
| |
XDRAWABLE |
type
plotter_parameter =
| |
DISPLAY of string |
| |
BITMAPSIZE of string |
| |
PAGESIZE of string |
| |
ROTATION of string |
| |
BG_COLOR of string |
| |
EMULATE_COLOR of bool |
| |
MAX_LINE_LENGTH of int |
| |
INTERLACE of bool |
| |
TRANSPARENT_COLOR of string |
| |
CGM_ENCODING of string |
| |
CGM_MAX_VERSION of string |
| |
GIF_ANIMATION of bool |
| |
GIF_DELAY of int |
| |
GIF_ITERATIONS of int |
| |
HPGL_ASSIGN_COLORS of bool |
| |
HPGL_OPAQUE_MODE of bool |
| |
HPGL_PENS of string |
| |
HPGL_ROTATE of string |
| |
HPGL_VERSION of string |
| |
META_PORTABLE of bool |
| |
PCL_ASSIGN_COLORS of bool |
| |
PCL_BEZIERS of bool |
| |
PNM_PORTABLE of bool |
| |
TERM of string |
| |
USE_DOUBLE_BUFFERING of bool |
| |
VANISH_ON_DELETE of bool |
| |
X_AUTO_FLUSH of bool |
Plotter parameters can be specified at creation time, either by passing
them to the function
Plot.makepl
, or by reading the corresponding
environment variable. The all have sensible default values. Not all
parameters make sense, depending of the plotter format.
Exceptions
The libplot
error handler raise the Error
exception.
The Deleted_plotter
exception is raised whenever an operation
is attempted on an already deleted plotter.
The Undeleted_plotter
exception is raised when the GC is
about to reclaim a plotter
value that has not been deleted
yet (see Plot.deletepl
).
The default warnings handler is to print messages on the error channel
(if one was set when the plotter was created). This handler can be set
by the function warnings
. warnings_as_errors
makes every warning
raise an Error
exception.
exception Error of string
exception Deleted_plotter
exception Undeleted_plotter
val warnings : (string -> unit) -> unit
val warnings_as_errors : unit -> unit
Creating & deleting plotters
The makepl
function is used to create a plotter.
It takes as argument a plotter_format
, a list of
plotter_parameter
and one or two channels. The first one is
the output channel. X plotters don't need any in fact so just put stdout.
The second one is the error channel : warnings are printed on it. It is
optionnal ; by default warnings are not printed.
The deletepl
function destroys the plotter given as argument. For
most of the plotter formats, it triggers the actual output of the data
to the output channel. The libplot
datatype is then freed. Any
subsequent use of this plotter will raise a Deleted_plotter
exception. On the contrary, if the plotter value becomes unreachable and
is about to be reclaimed by the GC and if it has not been deleted yet,
Undeleted_plotter
will be raised.
The utility function format_of_string
returns a plotter_format
given a string (e.g format_of_string "png"
returns PNG
).
val version : string
Library version
val format_of_string : string -> plotter_format
val string_of_format : plotter_format -> string
val makepl : plotter_format ->
Pervasives.out_channel ->
?err_channel:Pervasives.out_channel ->
plotter_parameter list -> plotter
val deletepl : plotter -> unit
Plotting functions
In libplot
, all drawing functions go by pair : one is taking
integer arguments, the other one (which has its name prefixed by an
f) takes double arguments. Libplot
uses doubles internaly and the
integer-arguments functions are only present for compatiblity
reasons. In Ocamlplot, all functions take float
arguments : the
f-named one behave like the C functions ; the other one use
arguments of type point
, that is a record of two floats.
All these functions are described in section 9.4 of the plotutils
manual. The f-named ones are external
, the others are just
straightforward wrappers for the external
or aliases.
type
point = {
}
Type for pairs of coordinates
val pi : float
val twopi : float
type
color =
| |
Colorname of string |
| |
RGB of int * int * int |
There are two ways of specifying colors with libplot
: either
by giving the red, green and blue values or by giving a name
(libplot
has a pretty big table of known color names). This
is done by using the color
variant type. The rgb values are 16 bit
ints (between 0x0000
and 0xffff
).
Control functions
val openpl : plotter -> unit
val bgcolor : plotter -> color -> unit
val erase : plotter -> unit
val space : plotter -> p0:point -> p1:point -> unit
val fspace : plotter -> x0:float -> y0:float -> x1:float -> y1:float -> unit
val space2 : plotter -> p0:point -> p1:point -> p2:point -> unit
val fspace2 : plotter ->
x0:float -> y0:float -> x1:float -> y1:float -> x2:float -> y2:float -> unit
val havecap : plotter -> s:string -> unit
val flushpl : plotter -> unit
val closepl : plotter -> unit
Object drawing functions
type
h_justify =
| |
Left |
| |
Center_h |
| |
Right |
type
v_justify =
| |
Bottom |
| |
Baseline |
| |
Center_v |
| |
Cap_line |
| |
Top |
val alabel : plotter -> h_justify -> v_justify -> string -> unit
val arc : plotter -> pc:point -> p0:point -> p1:point -> unit
val farc : plotter ->
xc:float -> yc:float -> x0:float -> y0:float -> x1:float -> y1:float -> unit
val arcrel : plotter -> dpc:point -> dp0:point -> dp1:point -> unit
val farcrel : plotter ->
dxc:float ->
dyc:float -> dx0:float -> dy0:float -> dx1:float -> dy1:float -> unit
val bezier2 : plotter -> p0:point -> p1:point -> p2:point -> unit
val fbezier2 : plotter ->
x0:float -> y0:float -> x1:float -> y1:float -> x2:float -> y2:float -> unit
val bezier2rel : plotter -> dp0:point -> dp1:point -> dp2:point -> unit
val fbezier2rel : plotter ->
dx0:float ->
dy0:float -> dx1:float -> dy1:float -> dx2:float -> dy2:float -> unit
val bezier3 : plotter ->
p0:point -> p1:point -> p2:point -> p3:point -> unit
val fbezier3 : plotter ->
x0:float ->
y0:float ->
x1:float -> y1:float -> x2:float -> y2:float -> x3:float -> y3:float -> unit
val bezier3rel : plotter ->
dp0:point -> dp1:point -> dp2:point -> dp3:point -> unit
val fbezier3rel : plotter ->
dx0:float ->
dy0:float ->
dx1:float ->
dy1:float -> dx2:float -> dy2:float -> dx3:float -> dy3:float -> unit
val box : plotter -> p0:point -> p1:point -> unit
val fbox : plotter -> x0:float -> y0:float -> x1:float -> y1:float -> unit
val boxrel : plotter -> dp0:point -> dp1:point -> unit
val fboxrel : plotter -> dx0:float -> dy0:float -> dx1:float -> dy1:float -> unit
val circle : plotter -> p:point -> r:float -> unit
val fcircle : plotter -> x:float -> y:float -> r:float -> unit
val circlerel : plotter -> dp:point -> r:float -> unit
val fcirclerel : plotter -> dx:float -> dy:float -> r:float -> unit
val cont : plotter -> p:point -> unit
val fcont : plotter -> x:float -> y:float -> unit
val contrel : plotter -> p:point -> unit
val fcontrel : plotter -> dx:float -> dy:float -> unit
val ellarc : plotter -> pc:point -> p0:point -> p1:point -> unit
val fellarc : plotter ->
xc:float -> yc:float -> x0:float -> y0:float -> x1:float -> y1:float -> unit
val ellarcrel : plotter -> dpc:point -> dp0:point -> dp1:point -> unit
val fellarcrel : plotter ->
dxc:float ->
dyc:float -> dx0:float -> dy0:float -> dx1:float -> dy1:float -> unit
val ellipse : plotter -> pc:point -> rx:float -> ry:float -> angle:float -> unit
val fellipse : plotter ->
x:float -> y:float -> rx:float -> ry:float -> angle:float -> unit
val ellipserel : plotter -> dpc:point -> rx:float -> ry:float -> angle:float -> unit
val fellipserel : plotter ->
dx:float -> dy:float -> rx:float -> ry:float -> angle:float -> unit
val endpath : plotter -> unit
val endsubpath : plotter -> unit
val closepath : plotter -> unit
val label : plotter -> s:string -> unit
val labelwidth : plotter -> string -> float
val flabelwidth : plotter -> string -> float
val line : plotter -> p0:point -> p1:point -> unit
val fline : plotter -> x0:float -> y0:float -> x1:float -> y1:float -> unit
val linerel : plotter -> dp0:point -> dp1:point -> unit
val flinerel : plotter -> dx0:float -> dy0:float -> dx1:float -> dy1:float -> unit
type
marker =
| |
No_marker |
| |
Dot |
| |
Plus |
| |
Asterisk |
| |
Circle |
| |
Cross |
| |
Square |
| |
Triangle |
| |
Diamont |
| |
Star |
| |
Inv_triangle |
| |
Starburst |
| |
Marker of int |
val marker : plotter -> point -> marker -> size:float -> unit
val fmarker : plotter -> x:float -> y:float -> marker -> size:float -> unit
val markerrel : plotter -> point -> marker -> size:float -> unit
val fmarkerrel : plotter -> x:float -> y:float -> marker -> size:float -> unit
val point : plotter -> p:point -> unit
val fpoint : plotter -> x:float -> y:float -> unit
val pointrel : plotter -> dp:point -> unit
val fpointrel : plotter -> dx:float -> dy:float -> unit
Attribute setting functions
type
capmod =
| |
Butt |
| |
Round_c |
| |
Projecting |
| |
Triangular |
val capmod : plotter -> capmod -> unit
val color : plotter -> color -> unit
val fillcolor : plotter -> color -> unit
val pencolor : plotter -> color -> unit
type
fillmod =
val fillmod : plotter -> fillmod -> unit
val filltype : plotter -> level:int -> unit
val fmiterlimit : plotter -> limit:float -> unit
val fontname : plotter -> string -> float
val ffontname : plotter -> string -> float
val fontsize : plotter -> float -> float
val ffontsize : plotter -> float -> float
type
joinmod =
| |
Miter |
| |
Round_j |
| |
Bevel |
val joinmod : plotter -> joinmod -> unit
val linedash : plotter -> dashes:int array -> offset:int -> unit
val flinedash : plotter -> dashes:float array -> offset:float -> unit
type
linemod =
| |
Solid |
| |
Dotted |
| |
Dotdashed |
| |
Shortdashed |
| |
Longdashed |
| |
Dotdotdashed |
| |
Dotdotdotdashed |
| |
Disconnected |
val linemod : plotter -> linemod -> unit
val linewidth : plotter -> size:float -> unit
val flinewidth : plotter -> size:float -> unit
val move : plotter -> p:point -> unit
val moverel : plotter -> p:point -> unit
val fmove : plotter -> x:float -> y:float -> unit
val fmoverel : plotter -> dx:float -> dy:float -> unit
type
direction =
| |
Clockwise |
| |
Counterclockwise |
val orientation : plotter -> direction -> unit
val textangle : plotter -> float -> float
val ftextangle : plotter -> float -> float
val pentype : plotter -> level:int -> unit
val restorestate : plotter -> unit
val savestate : plotter -> unit
Matrix functions
val fsetmatrix : plotter ->
m0:float -> m1:float -> m2:float -> m3:float -> m4:float -> m5:float -> unit
val fconcat : plotter ->
m0:float -> m1:float -> m2:float -> m3:float -> m4:float -> m5:float -> unit
val frotate : plotter -> theta:float -> unit
val fscale : plotter -> x:float -> y:float -> unit
val ftranslate : plotter -> x:float -> y:float -> unit