Difference between revisions of "OCaml tutorial"
(Created page with '== Intro == The [http://caml.inria.fr OCaml] bindings for PLplot provide three means of accessing PLplot's functionality through three modules, Plplot, Plplot.Plot and Plplot.Qu…') |
m (→Using the Quick_plot module: Fix plot axis labeling) |
||
Line 20: | Line 20: | ||
Quick_plot.func | Quick_plot.func | ||
− | ~labels:("Angle (radians)", " | + | ~labels:("Angle (radians)", "f(x)", "A few functions") |
~names:["sin"; "cos"] | ~names:["sin"; "cos"] | ||
− | [sin; cos] (-3. | + | [sin; cos] (-3.15, 3.15) |
with output which looks something like this: | with output which looks something like this: |
Latest revision as of 12:06, 18 October 2009
Intro
The OCaml bindings for PLplot provide three means of accessing PLplot's functionality through three modules, Plplot, Plplot.Plot and Plplot.Quick_plot. In versions 5.9.6 and later the OCaml sections of the PLplot documentation includes a tutorial which introduces each of these modules. This tutorial is meant to expand on that material and allow for a simpler process for contributing improvements.
Using the Quick_plot module
The main OCaml PLplot module is meant to be open'd:
open Plplot
From here, one can try out a quick plot of sin and cos:
Quick_plot.func [sin; cos] (-3.14, 3.14)
which gives output which looks something like this:
That's great, but it would be even better if there were labels so that we know what the axes mean and a legend to show which line corresponds with which function. We can do that:
Quick_plot.func ~labels:("Angle (radians)", "f(x)", "A few functions") ~names:["sin"; "cos"] [sin; cos] (-3.15, 3.15)
with output which looks something like this:
Much better, and much easier to interpret!