带有PLPLPLOT、OCaml的标题

带有PLPLPLOT、OCaml的标题,plot,ocaml,Plot,Ocaml,我想用OCaml中的PLplot绑定为我的图形添加标题。到目前为止,我的代码如下所示: let simple_example g filename = let p = P.init (0.0, -2.0) (10.0, 2.0) `greedy (`svg `core) ~filename:filename in P.plot ~stream:p [P.func `blue g (0.0, 10.0) ~step:0.001]; P.finish ~stream:p (

我想用OCaml中的PLplot绑定为我的图形添加标题。到目前为止,我的代码如下所示:

let simple_example g filename =
  let p =
    P.init (0.0, -2.0) (10.0, 2.0) `greedy (`svg `core) ~filename:filename
  in

  P.plot ~stream:p [P.func `blue g (0.0, 10.0) ~step:0.001];
  P.finish ~stream:p ();
  ;;
我查看了
plplplot.mli
文件,并尝试在函数之外使用
text
an
text\u,但未成功。我知道有
Quick_plot
模块,它使我能够轻松地编写标题,但我想避免它,因为我失去了很多其他选项

编辑。

我看了一下“规范”示例,但没有成功(此处:)

您可以从提供使用ocaml和其他语言的示例的网站获得帮助

我设法在抛物线图上显示了一个标签:

      let simple_example () =
      let xs = Array.init 21 (fun xi -> float xi -. 10.0) in
      let ys = Array.map (fun x -> x**2.0) xs in
      plinit ();
      plenv (-10.0) 10.0 0.0 100.0 0 0;
      plline xs ys;
      pllab "(x)" "(y)" "#frPLplot Example 1 - y=x#u2";
      plend();
      ();;             
如果您想使用Plplot中的Plot模块,只需将其添加到给p.Plot的列表中,如下所示:

let simple_example g filename =
  let p =
    P.init (0.0, -2.0) (10.0, 2.0) `greedy (`svg `core) ~filename:filename
  in

  P.plot ~stream:p [P.func `blue g (0.0, 10.0) ~step:0.001; P.text `blue 0. 0. "function"];
  P.finish ~stream:p ();
  ;;

函数
p.label
应该执行您想要的操作:


此函数是
Plot
模块的等效函数,相当于
pllab

谢谢,我曾考虑过使用此函数,但我正在寻找使用语法p.Init,p.Plot,p.Finish的解决方案。对我来说,它似乎更具可读性。