2016-12-26 33 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