Commits

Guillaume Hennequin committed 57b1067

ocp-indent

  • Participants
  • Parent commits a1bd553

Comments (0)

Files changed (3)

File examples/ex.ml

   
 (* simple y-vector plot *)
 let _ =
-  let f = Gp.figure() in
+  let f = Gp.figure () in
   Gp.send ["set xlabel 'trial #'";
     "set ylabel 'value";
     "set title 'random stuff'";
   Gp.plot [[unif],"w p pt 7 lc 7 ps 0.2"] f;
   Gp.close f
   
+(*
 (* double y-vector plot, quick shortcut *)
 let expo = Array.map exp unif
 let _ = Gp.quick (Gp.plot
 let _ =
   let f = Gp.figure() in
   Gp.plot [[x;y1],"w l ls 1";
-    [x;y2],"w l ls 3"] f;
-  Gp.close f
+    [x;y2],"w l ls 3"] f
   
 (* smooth histogram *)
 let _ =
   let f = Gp.figure() in
   Gp.send ["unset ytics"] f;
-  Gp.plot [[unif],"u 1:0:(0.01) w l ls 7 smooth kdensity"] f;
-  Gp.close f
+  Gp.plot [[unif],"u 1:0:(0.01) w l ls 7 smooth kdensity"] f
   
   
 (* plot all of the above in a multiplot setting *)
   Gp.plot [[x;y1],"w l ls 1";
     [x;y2],"w l ls 3"] f;
   Gp.plot [[unif],"u 1:0:(0.01) w l ls 7 smooth kdensity"] f;
-  Gp.send ["unset multiplot"] f;
-  Gp.close f
+  Gp.send ["unset multiplot"] f
   
   
   
     Gp.plot [[x;y1],"w l ls 1";
       [x;y2],"w l ls 3"];
     Gp.plot [[unif],"u 1:0:(0.01) w l ls 7 smooth kdensity"] ]
-  f;
-  Gp.close f
+  f
+
+*)
 open Printf
 
 let gnuplot = "gnuplot" (* command name *)
-  
+
 type t = out_channel
-  
+
 let figure ?device () =
   let f = Unix.open_process_out gnuplot in
   begin match device with
     | None -> output_string f "set term wxt enhanced persist\n"
     | Some (terminal,"") -> output_string f (sprintf "set term %s\n" terminal);
     | Some (terminal,file) -> (
-          output_string f (sprintf "set term %s\n" terminal) ;
-          output_string f (sprintf "set output '%s'\n" file))
+        output_string f (sprintf "set term %s\n" terminal) ;
+        output_string f (sprintf "set output '%s'\n" file))
   end;
   f
-  
+
 let send list (f:t) = List.iter (fun s -> output_string f (s^"\n")) list
-  
+
 let flush = flush
-  
+
 let close f = ignore (Unix.close_process_out f)
-  
+
 let end_signal f = fprintf f "e\n%!"
-  
+
 let send_columns m f =
   let cols = Array.length m in
   let rows = Array.fold_left max (-1) (Array.map Array.length m) in
     done; fprintf f "\n%!";
   done;
   end_signal f
-  
-  
-  (* for some reason, gnuplot wants a double "e" at the end
-     of the stream for matrix data given to [splot()] ... *)
-  
+
+
+(* for some reason, gnuplot wants a double "e" at the end
+   of the stream for matrix data given to [splot()] ... *)
+
 let send_matrix m f =
   send_columns m f;
   end_signal f
-  
+
 let plot data f =
   let cmds = List.map (fun (_,opts) -> sprintf "'-' %s" opts) data in
   let cmd = "plot " ^ String.concat ", " cmds in
   send [cmd] f;
   List.iter (fun (d,_) -> send_columns (Array.of_list d) f) data
-  
-  
+
+
 let splot data f =
   let mat,opts = data in
   send ["set pm3d map"; "set key noautotitle"] f;
     sprintf "splot '-' %s" opts
   ] f;
   send_matrix mat f
-  
+
 let margins ?t ?b ?l ?r f =
   let setm s x = match x with
     | Some m -> send [sprintf "set %smargin at screen %f" s m] f
     | None -> () in
   setm "t" t; setm "b" b; setm "l" l; setm "r" r
-  
+
 let xrange a b f =
   send [sprintf "set xrange [%f:%f]" a b] f
-  
+
 let yrange a b f =
   send [sprintf "set yrange [%f:%f]" a b] f
-  
+
 let title s f =
   send [sprintf "set title '%s'" s] f
-  
+
 let multiplot rows cols vspace hspace list f =
   send [sprintf "set multiplot layout %i,%i" rows cols] f;
   let plots = Array.of_list list in
     plots.(k) f;
   done;
   send ["unset multiplot"] f
-  
-  
+
+
 let quick doThis =
   let f = figure() in
   doThis f;
   close f
+
   
-  
    [~device:(terminal, file)] specifies where the plot should be performed
    (e.g. [("pdf enhanced size 10cm,8cm font 'Luxi Sans, 6'", "my_plot.pdf")]) *)
 val figure : ?device:string * string -> unit -> t
-   
+
 (** send a command (string) to Gnuplot for direct execution *)
 val send : string list -> t -> unit
-   
+
 (** flush the command queue *)
 val flush : t -> unit
-   
+
 (** close the gnuplot instance *)
 val close : t -> unit
-   
+
 (** send a vector of columns to gnuplot ;
    the columns are actually the lines of your vectors, i.e.
    [sendColumns [| col1; col2; ... |]] ;
    useful with [plot '-'] *)
 val send_columns : float array array -> t -> unit
-   
+
 (** send matrix data to gnuplot -- for use with [splot()] *)
 val send_matrix : float array array -> t -> unit
-   
+
 (** plot data ; this is rather flexible, you can do stuff like
    {[ plot [[x1;y1], "t 'foo' w l ls 7";
    [y2], "w p pt 7 lc 7, sin(x) w l lc 3"] f ]} *)
 val plot : (float array list * string) list -> t -> unit
-   
+
 (** [splot mat f] plots matrix [mat] in heat map form *)
 val splot : (float array array * string) -> t -> unit
-   
-   
-   (** some useful shortcuts *)
-   
+
+
+(** some useful shortcuts *)
+
 (** very useful to align stuff in multiplot.
    Margins should be given as percentage of total screen area *)
 val margins : ?t:float -> ?b:float -> ?l:float -> ?r:float -> t -> unit
-   
+
 val xrange : float -> float -> t -> unit
-   
+
 val yrange : float -> float -> t -> unit
-   
+
 val title : string -> t -> unit
-   
+
 (** organize a set of plots in a multiplot layout form,
    with given spaces between rows and columns;
    [multiplot 2 1 0.05 0.05 [[x1;y1],"w l lc 1";[x2;y2],"w l lc 3"]] *)
 val multiplot : int -> int -> float -> float -> (t -> 'a) list -> t -> unit
-   
+
 (** quick plotting -- does the figure creation for you, but you don't have access
    to it since it's closed right after your plot;
    e.g. [quick (plot [[a;b],"w l lc 7"])] *)
 val quick : (t -> unit) -> unit
+
    
-