1(*
2   Simple demo of a 2D line plot.
3
4   Copyright (C) 2011  Alan W. Irwin
5   Copyright (C) 2012  Andrew Ross
6
7   This file is part of PLplot.
8
9   PLplot is free software; you can redistribute it and/or modify
10   it under the terms of the GNU Library General Public License as published
11   by the Free Software Foundation; either version 2 of the License, or
12   (at your option) any later version.
13
14   PLplot is distributed in the hope that it will be useful,
15   but WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   GNU Library General Public License for more details.
18
19   You should have received a copy of the GNU Library General Public License
20   along with PLplot; if not, write to the Free Software
21   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
23*)
24
25open Plplot
26
27let nsize = 101
28
29let () =
30  let xmin = 0.0 in
31  let xmax = 1.0 in
32  let ymin = 0.0 in
33  let ymax = 100.0 in
34
35  (* Prepare data to be plotted. *)
36  let x = Array.init nsize (fun i -> float_of_int i /. ( float_of_int nsize -. 1.0)) in
37  let y = Array.init nsize (fun i -> ymax *. x.(i) *. x.(i) ) in
38
39  (* Parse and process command line arguments *)
40  plparseopts Sys.argv [PL_PARSE_FULL];
41
42  (* Initialize plplot *)
43  plinit ();
44
45  (* Create a labelled box to hold the plot. *)
46  plenv xmin xmax ymin ymax 0 0 ;
47  pllab "x" "y=100 x#u2#d" "Simple PLplot demo of a 2D line plot" ;
48
49  (* Plot the data that was prepared above. *)
50  plline x y;
51
52  (* Close PLplot library *)
53  plend ();
54  ()
55
56