Plot.ml

(* Copyright INRIA and Microsoft Corporation, 2008-2013. *)
(* DDMF is distributed under CeCILL-B license. *)

INCLUDE "preamble.ml"

let plot_and_range proc min max =
  let plot =
    <<
      plots[display](plot($(proc), $(min)..$(max), numpoints=200, color=blue))
    >> in
  (plot, << DynaMoW:-GetViewPort($(plot)) >>)

let_service PlotSVG
  (proc : any maple)
  (min : any maple)
  (max : any maple) :
  DynaMoW.Services.svg * unit =
  let plot, range = plot_and_range proc min max in
  (<:string< DynaMoW:-PlotToSVG($(plot), $(range)) >>, ())

let title _ = <:text<Plot>>

(* TODO: validate values of min & max before calling PlotSVG. *)
let_service Plot
  (proc : any maple)
  (min : string = Constants.default_plot_min_abs)
  (max : string = Constants.default_plot_max_abs) :
  DC.sec_entities * unit with { title = title } =
  let body =
    DC.plot
      (PlotSVG.descr
        (proc, Maple.evaluator_symbolic min, Maple.evaluator_symbolic max)
        None) in
  DC.section (title _req_params) <:par< $(body) >>, ()

Generated by GNU Enscript 1.6.5.90.