Summary: This example shows how to create 3D-IsoSurface charts in F#.
Let's first create some data for the purpose of creating example charts:
open System
open Plotly.NET
let linspace (min, max, n) =
if n <= 2 then
failwithf "n needs to be larger then 2"
let bw = float (max - min) / (float n - 1.)
Array.init n (fun i -> min + (bw * float i))
let mgrid (min, max, n) =
let data = linspace (min, max, n)
let z =
[| for i in 1..n do
[| for i in 1..n do
yield data |] |]
let x =
[| for i in 1..n do
[| for j in 1..n do
yield
[| for k in 1..n do
yield data.[i - 1] |] |] |]
let y =
[| for i in 1..n do
[| for j in 1..n do
yield
[| for k in 1..n do
yield data.[j - 1] |] |] |]
x, y, z
let xIso, yIso, zIso =
mgrid (-5., 5., 40)
|> fun (x, y, z) ->
(x |> Array.concat |> Array.concat), (y |> Array.concat |> Array.concat), (z |> Array.concat |> Array.concat)
let valueIso =
Array.map3 (fun x y z -> x * x * 0.5 + y * y + z * z * 2.) xIso yIso zIso
open Plotly.NET.TraceObjects
let isoSurface =
Chart.IsoSurface(
x = xIso,
y = yIso,
z = zIso,
value = valueIso,
IsoMin = 10.,
IsoMax = 40.,
Caps = Caps.init (X = (CapFill.init (Show = false)), Y = (CapFill.init (Show = false))),
Surface = Surface.init (Count = 5)
)