2016-12-26 34 views
2

我想用OCaml中的PLplot绑定将标题放到我的图中。到目前为止,我的代码看起来是这样的:标题与PLplot,OCaml

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(); 
    ;; 

我看看plplot.mli文件,并试图用texttext_outside功能,不成功。我知道有Quick_plot模块,它使我可以轻松地编写标题,但我想避免它,因为我失去了很多其他选项。

编辑。

我看了一下“规范”的例子,但没有成功(这里:http://plplot.sourceforge.net/docbook-manual/plplot-html-5.11.1/ocaml_howto.html

回答

1

您可以从PLplot网站使用其他语言中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绘图模块,您只需要添加到您给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(); 
    ;; 
+0

谢谢你,我想过使用这个,但我正在寻找一个解决方案,使用语法P.Init,P.plot,P.Finish它似乎更易于阅读。 – RUser4512