From: <hez...@us...> - 2009-10-05 21:08:59
|
Revision: 10514 http://plplot.svn.sourceforge.net/plplot/?rev=10514&view=rev Author: hezekiahcarty Date: 2009-10-05 21:08:49 +0000 (Mon, 05 Oct 2009) Log Message: ----------- Change Plplot.Plot API slightly to make more function parameters optional plot_axes, finish_page, next_page and finish all work when no tick spacing or subtick count is provided. When no values are provided for these, the PLplot defaults are used. xplot01.ml is also updated to reflect these changes. Modified Paths: -------------- trunk/bindings/ocaml/plplot.ml trunk/bindings/ocaml/plplot.mli trunk/examples/ocaml/xplot01.ml Modified: trunk/bindings/ocaml/plplot.ml =================================================================== --- trunk/bindings/ocaml/plplot.ml 2009-10-05 21:06:17 UTC (rev 10513) +++ trunk/bindings/ocaml/plplot.ml 2009-10-05 21:08:49 UTC (rev 10514) @@ -919,7 +919,8 @@ with_stream ?stream (fun () -> colorbar ?label ?log ?pos ?width values) (** An easier to deduce alternative to {Plplot.plbox} *) - let plot_axes ?stream ~xtick ~xsub ~ytick ~ysub ~xoptions ~yoptions = + let plot_axes ?stream ?(xtick = 0.0) ?(xsub =0) + ?(ytick = 0.0) ?(ysub = 0) xoptions yoptions = let map_axis_options ol = List.map ( function @@ -945,7 +946,7 @@ with_stream ?stream (fun () -> plbox xopt xtick xsub yopt ytick ysub) (** Default page ending steps. Just draw the plot axes. *) - let default_finish ?stream ?axis xstep ystep = + let default_finish ?stream ?axis ?xtick ?ytick () = let xopt, yopt = match axis with | None -> default_axis_options, default_axis_options @@ -953,29 +954,27 @@ in set_color_in ?stream Black ( fun () -> - plot_axes ?stream - ~xtick:xstep ~xsub:0 ~xoptions:xopt - ~ytick:ystep ~ysub:0 ~yoptions:yopt; + plot_axes ?stream ?xtick xopt ?ytick yopt; ) (** Plot axes, but don't advance the page or end the session. This is used internally by [finish]. *) - let finish_page ?stream ?f ?post ?axis xstep ystep = + let finish_page ?stream ?f ?post ?axis ?xtick ?ytick () = with_stream ?stream ( fun () -> let actual_finish = match f with | Some custom_finish -> custom_finish - | None -> (fun () -> default_finish ?stream ?axis xstep ystep) + | None -> default_finish ?stream ?axis ?xtick ?ytick in actual_finish (); Option.may (fun f -> f ()) post; ) (** Finish the current page, start a new one. *) - let next_page ?stream ?f ?post ?axis ?(xstep = 0.0) ?(ystep = 0.0) + let next_page ?stream ?f ?post ?axis ?xtick ?ytick (x0, y0) (x1, y1) axis_scaling = - finish_page ?stream ?f ?post ?axis xstep ystep; + finish_page ?stream ?f ?post ?axis ?xtick ?ytick (); start_page ?stream (x0, y0) (x1, y1) axis_scaling; () @@ -985,8 +984,8 @@ (** Finish up the plot by plotting axes and ending the session. This must be called after plotting is complete. *) - let finish ?stream ?f ?post ?axis xstep ystep = - finish_page ?stream ?f ?post ?axis xstep ystep; + let finish ?stream ?f ?post ?axis ?xtick ?ytick () = + finish_page ?stream ?f ?post ?axis ?xtick ?ytick (); with_stream ?stream plend1 end @@ -1051,7 +1050,7 @@ in plot ~stream:p plottable_points; Option.may (fun (x, y, t) -> label ~stream:p x y t) labels; - finish ~stream:p ~axis:(maybe_log log) 0.0 0.0; + finish ~stream:p ~axis:(maybe_log log) (); () (** [lines [xs, ys; ...] plots the line segments described by the coordinates @@ -1072,7 +1071,7 @@ plot ~stream:p plottable_lines; Option.may (fun (x, y, t) -> label ~stream:p x y t) labels; Option.may (fun n -> draw_legend ~stream:p n (Array.to_list colors)) names; - finish ~stream:p ~axis:(maybe_log log) 0.0 0.0; + finish ~stream:p ~axis:(maybe_log log) (); () (** [image ?log m] plots the image [m] with a matching colorbar. If [log] is @@ -1088,7 +1087,7 @@ Option.may (fun (x, y, t) -> label ~stream:p x y t) labels; colorbar ~stream:p ?log ~pos:(Right 0.12) (Array_ext.range ~n:100 m_min m_max); - finish ~stream:p 0.0 0.0; + finish ~stream:p (); () (** [func ?point ?step fs (min, max)] plots the functions [fs] from [x = min] @@ -1122,7 +1121,7 @@ plot ~stream plot_content; Option.may (fun n -> draw_legend ~stream n (Array.to_list colors)) names; Option.may (fun (x, y, t) -> label ~stream x y t) labels; - finish ~stream 0.0 0.0; + finish ~stream (); () end Modified: trunk/bindings/ocaml/plplot.mli =================================================================== --- trunk/bindings/ocaml/plplot.mli 2009-10-05 21:06:17 UTC (rev 10513) +++ trunk/bindings/ocaml/plplot.mli 2009-10-05 21:08:49 UTC (rev 10514) @@ -369,11 +369,11 @@ (** Draw the plot axes on the current plot page *) val plot_axes : ?stream:stream_t -> - xtick:float -> - xsub:int -> - ytick:float -> - ysub:int -> - xoptions:axis_options_t list -> yoptions:axis_options_t list -> unit + ?xtick:float -> + ?xsub:int -> + ?ytick:float -> + ?ysub:int -> + axis_options_t list -> axis_options_t list -> unit (** {4 Finishing up a plot page} *) @@ -384,7 +384,8 @@ ?f:(unit -> unit) -> ?post:(unit -> unit) -> ?axis:axis_options_t list * axis_options_t list -> - float -> float -> unit + ?xtick:float -> ?ytick:float -> + unit -> unit (** Finish the current page, start a new one. *) val next_page : @@ -392,8 +393,8 @@ ?f:(unit -> unit) -> ?post:(unit -> unit) -> ?axis:axis_options_t list * axis_options_t list -> - ?xstep:float -> - ?ystep:float -> + ?xtick:float -> + ?ytick:float -> float * float -> float * float -> plot_scaling_t -> unit (** [finish ?stream xstep ystep] finishes up the plot [stream], using @@ -403,7 +404,8 @@ ?f:(unit -> unit) -> ?post:(unit -> unit) -> ?axis:axis_options_t list * axis_options_t list -> - float -> float -> unit + ?xtick:float -> ?ytick:float -> + unit -> unit end (** {3 A module for quick, "throw-away" plots} *) Modified: trunk/examples/ocaml/xplot01.ml =================================================================== --- trunk/examples/ocaml/xplot01.ml 2009-10-05 21:06:17 UTC (rev 10513) +++ trunk/examples/ocaml/xplot01.ml 2009-10-05 21:08:49 UTC (rev 10514) @@ -101,7 +101,7 @@ ]; (* Show the axes *) - P.finish_page ~stream 0.0 0.0; + P.finish_page ~stream (); (* All done. *) stream @@ -136,7 +136,7 @@ P.Axis :: P.default_axis_options, P.Axis :: P.default_axis_options in - P.finish_page ~stream ~axis 0.0 0.0; + P.finish_page ~stream ~axis (); (* All done. *) () @@ -154,7 +154,7 @@ fun () -> plstyl [|mark1|] [|space1|]; P.set_color P.Yellow; - P.plot_axes 30.0 0 0.2 0 [P.Major_grid] [P.Major_grid]; + P.plot_axes ~xtick:30.0 ~ytick:0.2 [P.Major_grid] [P.Major_grid]; plstyl [||] [||]; ); @@ -180,7 +180,7 @@ ] in - P.finish_page ~stream ~axis 60.0 0.2; + P.finish_page ~stream ~axis ~xtick:60.0 ~ytick:0.2 (); (* All done. *) () @@ -234,7 +234,7 @@ (* Don't forget to finish off! Each function does the needed end-of-page steps, so all we need to do here is wrap up the plotting session. *) - P.finish ~stream ~f:(fun () -> ()) 0.0 0.0; + P.finish ~stream ~f:(fun () -> ()) (); () let () = main true This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |