File: ex8.ml

package info (click to toggle)
ocaml-gnuplot 0.8.3-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 508 kB
  • sloc: ml: 2,148; makefile: 185
file content (38 lines) | stat: -rw-r--r-- 829 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(* 	$Id: ex8.ml,v 1.2 2004-11-22 19:54:26 chris_77 Exp $	 *)
(* Functor and text demonstration *)

open Parse_args

(* Data structure *)
module Data =
struct
  type vec = (float * string) list
  let iter f vec = List.iter (fun (x,_) -> f x) vec

  type vec2 = (float * float * string) list
  let iter2 f vec2 = List.iter (fun (x,y,_) -> f x y) vec2

  type vec4 = unit
  type mat = unit
  let iter4 _ = failwith "Data.iter4"
  let iter_mat _ = failwith "Data.iter_mat"
end

module P = Gnuplot.Make(Data)

let labelled_xy = [
  (1., 4., "hello");
  (2., 0., "Bonjour");
]

let () =
  let g = P.init ?offline:(offline 1) (device 1) in
  P.box g;
  P.pen g 1;
  P.point g 3;
  P.point_width g 2.;
  List.iter (fun (x,y,t) ->
               P.text g x y t
            ) labelled_xy;
  P.xy g labelled_xy ~style:P.Points;
  P.close g