Sunday, 8 September 2013

F# for Visualization update

A new version of our F# for Visualization library has been released. This library makes it easy to create interactive 2D and 3D graphs using F# including mathematically typeset labels and annotations.

Watch this tutorial video and see the pictures below:

A labelled plot of a sine wave:

Plot([Function sin; Data xys], (-6., 6.), Labels=(Text "x", Text "sin(x)"))

F# for Visualization provides a handy View function that tries to visualize any value of any type, such as an F# PowerPack matrix of arbitrary-precision rational numbers:

let A =
    [ for i in 0N..4N ->
        [ for j in 0N..4N ->
            1N / (i + j + 1N) ] ]

View A

In combination with mathematical typesetting, this allows us to build up and visualize complicated expressions:

View(Row[math A; Symbols.Times; math(inverse A); math "="; math(A*inverse A)])

Arbitrary 2D vector graphics can be drawn, such as the following doodle:

let styles = [ Stroke(Brushes.Red, {width = 0.001}) ]

let geometry =
  let n = 50
  [ for i in 0 .. n do
      for j in 0 .. 1 do
        let x, y = float i / float n, float j
        yield Contour.Open(Point(x, y), [line_to y (1. - x)]) ]

View(Shape(styles, geometry))

Using a vector graphic as an Epilog allows it to be rendered with axes:

Plot([], (0., 1.), (0., 1.), Epilog=scene)

Plot a function of two variables in 3D:

let f x z =
  let r = 5. * sqrt(x*x + z*z)
  sin(r + 3. * x) / r
Plot3D(f, (-5., 5.), (-5., 5.), (-0.1, 1.))

Visualize a predefined mesh:

View(Shape3D(Polyhedra.Icosahedron.mesh, Brushes.White))

And many more features...

No comments: