Logo Plotly.NET

3D IsoSurface plots

Binder  Notebook

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)
    )
namespace Plotly
namespace Plotly.NET
module Defaults from Plotly.NET
<summary> Contains mutable global default values. Changing these values will apply the default values to all consecutive Chart generations. </summary>
val mutable DefaultDisplayOptions: Plotly.NET.DisplayOptions
Multiple items
type DisplayOptions = inherit DynamicObj new: unit -> DisplayOptions static member addAdditionalHeadTags: additionalHeadTags: XmlNode list -> (DisplayOptions -> DisplayOptions) static member addChartDescription: description: XmlNode list -> (DisplayOptions -> DisplayOptions) static member combine: first: DisplayOptions -> second: DisplayOptions -> DisplayOptions static member getAdditionalHeadTags: displayOpts: DisplayOptions -> XmlNode list static member getChartDescription: displayOpts: DisplayOptions -> XmlNode list static member getDocumentCharset: displayOpts: DisplayOptions -> string static member getDocumentDescription: displayOpts: DisplayOptions -> string static member getDocumentFavicon: displayOpts: DisplayOptions -> XmlNode ...

--------------------
new: unit -> Plotly.NET.DisplayOptions
static member Plotly.NET.DisplayOptions.init: ?DocumentTitle: string * ?DocumentCharset: string * ?DocumentDescription: string * ?DocumentFavicon: Giraffe.ViewEngine.HtmlElements.XmlNode * ?AdditionalHeadTags: Giraffe.ViewEngine.HtmlElements.XmlNode list * ?ChartDescription: Giraffe.ViewEngine.HtmlElements.XmlNode list * ?PlotlyJSReference: Plotly.NET.PlotlyJSReference -> Plotly.NET.DisplayOptions
type PlotlyJSReference = | CDN of string | Full | Require of string | NoReference
<summary> Sets how plotly is referenced in the head of html docs. </summary>
union case Plotly.NET.PlotlyJSReference.NoReference: Plotly.NET.PlotlyJSReference
namespace System
val linspace: min: float * max: float * n: int -> float array
val min: float
val max: float
val n: int
val failwithf: format: Printf.StringFormat<'T,'Result> -> 'T
val bw: float
Multiple items
val float: value: 'T -> float (requires member op_Explicit)

--------------------
type float = Double

--------------------
type float<'Measure> = float
type Array = interface ICollection interface IEnumerable interface IList interface IStructuralComparable interface IStructuralEquatable interface ICloneable member Clone: unit -> obj member CopyTo: array: Array * index: int -> unit + 1 overload member GetEnumerator: unit -> IEnumerator member GetLength: dimension: int -> int ...
<summary>Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the base class for all arrays in the common language runtime.</summary>
val init: count: int -> initializer: (int -> 'T) -> 'T array
val i: int
val mgrid: min: float * max: float * n: int -> float array array array * float array array array * float array array array
val data: float array
val z: float array array array
val x: float array array array
val j: int
val k: int
val y: float array array array
val xIso: float array
val yIso: float array
val zIso: float array
val concat: arrays: 'T array seq -> 'T array
val valueIso: float array
val map3: mapping: ('T1 -> 'T2 -> 'T3 -> 'U) -> array1: 'T1 array -> array2: 'T2 array -> array3: 'T3 array -> 'U array
val x: float
val y: float
val z: float
namespace Plotly.NET.TraceObjects
val isoSurface: GenericChart
type Chart = static member Bubble: x: #IConvertible seq * y: #IConvertible seq * sizes: int seq * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?MultiOpacity: float seq * ?Text: 'c * ?MultiText: 'c seq * ?TextPosition: TextPosition * ?MultiTextPosition: TextPosition seq * ?MarkerColor: Color * ?MarkerColorScale: Colorscale * ?MarkerOutline: Line * ?MarkerSymbol: MarkerSymbol * ?MultiMarkerSymbol: MarkerSymbol seq * ?Marker: Marker * ?LineColor: Color * ?LineColorScale: Colorscale * ?LineWidth: float * ?LineDash: DrawingStyle * ?Line: Line * ?AlignmentGroup: string * ?OffsetGroup: string * ?StackGroup: string * ?Orientation: Orientation * ?GroupNorm: GroupNorm * ?UseWebGL: bool * ?UseDefaults: bool -> GenericChart (requires 'c :> IConvertible) + 2 overloads static member Line: x: #IConvertible seq * y: #IConvertible seq * ?ShowMarkers: bool * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?MultiOpacity: float seq * ?Text: 'c * ?MultiText: 'c seq * ?TextPosition: TextPosition * ?MultiTextPosition: TextPosition seq * ?MarkerColor: Color * ?MarkerColorScale: Colorscale * ?MarkerOutline: Line * ?MarkerSymbol: MarkerSymbol * ?MultiMarkerSymbol: MarkerSymbol seq * ?Marker: Marker * ?LineColor: Color * ?LineColorScale: Colorscale * ?LineWidth: float * ?LineDash: DrawingStyle * ?Line: Line * ?AlignmentGroup: string * ?OffsetGroup: string * ?StackGroup: string * ?Orientation: Orientation * ?GroupNorm: GroupNorm * ?Fill: Fill * ?FillColor: Color * ?FillPattern: Pattern * ?UseWebGL: bool * ?UseDefaults: bool -> GenericChart (requires 'c :> IConvertible) + 2 overloads static member Point: x: #IConvertible seq * y: #IConvertible seq * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?MultiOpacity: float seq * ?Text: 'c * ?MultiText: 'c seq * ?TextPosition: TextPosition * ?MultiTextPosition: TextPosition seq * ?MarkerColor: Color * ?MarkerColorScale: Colorscale * ?MarkerOutline: Line * ?MarkerSymbol: MarkerSymbol * ?MultiMarkerSymbol: MarkerSymbol seq * ?Marker: Marker * ?AlignmentGroup: string * ?OffsetGroup: string * ?StackGroup: string * ?Orientation: Orientation * ?GroupNorm: GroupNorm * ?UseWebGL: bool * ?UseDefaults: bool -> GenericChart (requires 'c :> IConvertible) + 2 overloads static member Range: x: #IConvertible seq * y: #IConvertible seq * upper: #IConvertible seq * lower: #IConvertible seq * mode: Mode * ?Name: string * ?GroupName: string * ?ShowMarkers: bool * ?ShowLegend: bool * ?Text: 'e * ?MultiText: 'e seq * ?TextPosition: TextPosition * ?MultiTextPosition: TextPosition seq * ?MarkerColor: Color * ?MarkerColorScale: Colorscale * ?MarkerOutline: Line * ?MarkerSymbol: MarkerSymbol * ?MultiMarkerSymbol: MarkerSymbol seq * ?Marker: Marker * ?UpperMarker: Marker * ?LowerMarker: Marker * ?LineColor: Color * ?LineColorScale: Colorscale * ?LineWidth: float * ?LineDash: DrawingStyle * ?Line: Line * ?UpperLine: Line * ?LowerLine: Line * ?RangeColor: Color * ?RangePattern: Pattern * ?UpperText: 'f * ?MultiUpperText: 'f seq * ?LowerText: 'g * ?MultiLowerText: 'g seq * ?TextFont: Font * ?LowerName: string * ?UpperName: string * ?UseDefaults: bool -> GenericChart (requires 'e :> IConvertible and 'f :> IConvertible and 'g :> IConvertible) + 2 overloads static member Scatter: ?X: 'a seq * ?XEncoded: EncodedTypedArray * ?MultiX: 'a seq seq * ?Y: 'b seq * ?YEncoded: EncodedTypedArray * ?MultiY: 'b seq seq * ?Mode: Mode * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?MultiOpacity: float seq * ?Text: 'c * ?MultiText: 'c seq * ?TextPosition: TextPosition * ?MultiTextPosition: TextPosition seq * ?MarkerColor: Color * ?MarkerColorScale: Colorscale * ?MarkerOutline: Line * ?MarkerSymbol: MarkerSymbol * ?MultiMarkerSymbol: MarkerSymbol seq * ?Marker: Marker * ?LineColor: Color * ?LineColorScale: Colorscale * ?LineWidth: float * ?LineDash: DrawingStyle * ?Line: Line * ?AlignmentGroup: string * ?OffsetGroup: string * ?StackGroup: string * ?Orientation: Orientation * ?GroupNorm: GroupNorm * ?Fill: Fill * ?FillColor: Color * ?FillPattern: Pattern * ?UseWebGL: bool * ?UseDefaults: bool -> GenericChart (requires 'a :> IConvertible and 'b :> IConvertible and 'c :> IConvertible) + 3 overloads static member Spline: x: #IConvertible seq * y: #IConvertible seq * ?ShowMarkers: bool * ?Smoothing: float * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?MultiOpacity: float seq * ?Text: 'c * ?MultiText: 'c seq * ?TextPosition: TextPosition * ?MultiTextPosition: TextPosition seq * ?MarkerColor: Color * ?MarkerColorScale: Colorscale * ?MarkerOutline: Line * ?MarkerSymbol: MarkerSymbol * ?MultiMarkerSymbol: MarkerSymbol seq * ?Marker: Marker * ?LineColor: Color * ?LineColorScale: Colorscale * ?LineWidth: float * ?LineDash: DrawingStyle * ?Line: Line * ?AlignmentGroup: string * ?OffsetGroup: string * ?StackGroup: string * ?Orientation: Orientation * ?GroupNorm: GroupNorm * ?Fill: Fill * ?FillColor: Color * ?FillPattern: Pattern * ?UseWebGL: bool * ?UseDefaults: bool -> GenericChart (requires 'c :> IConvertible) + 2 overloads
static member Chart.IsoSurface: xEncoded: EncodedTypedArray * yEncoded: EncodedTypedArray * zEncoded: EncodedTypedArray * valueEncoded: EncodedTypedArray * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?Text: 'a * ?MultiText: 'a seq * ?ColorScale: StyleParam.Colorscale * ?ShowScale: bool * ?ColorBar: ColorBar * ?IsoMin: float * ?IsoMax: float * ?Caps: Caps * ?Slices: Slices * ?Surface: Surface * ?CameraProjectionType: StyleParam.CameraProjectionType * ?Camera: LayoutObjects.Camera * ?UseDefaults: bool -> GenericChart (requires 'a :> IConvertible)
static member Chart.IsoSurface: x: #IConvertible seq * y: #IConvertible seq * z: #IConvertible seq * value: #IConvertible seq * ?Name: string * ?ShowLegend: bool * ?Opacity: float * ?Text: 'e * ?MultiText: 'e seq * ?ColorScale: StyleParam.Colorscale * ?ShowScale: bool * ?ColorBar: ColorBar * ?IsoMin: float * ?IsoMax: float * ?Caps: Caps * ?Slices: Slices * ?Surface: Surface * ?CameraProjectionType: StyleParam.CameraProjectionType * ?Camera: LayoutObjects.Camera * ?UseDefaults: bool -> GenericChart (requires 'e :> IConvertible)
argument x: float seq
<summary> Creates a isosurface plot to visualize the volume of a 3D shape. An isosurface is a surface that represents points of a constant value (e.g. pressure, temperature, velocity, density) within a volume of space. Draws isosurfaces between iso-min and iso-max values with coordinates given by four 1-dimensional arrays containing the `value`, `x`, `y` and `z` of every vertex of a uniform or non-uniform 3-D grid. Horizontal or vertical slices, caps as well as spaceframe between iso-min and iso-max values could also be drawn using this trace. This plot is very similar to the `Volume` plot. However it shows all surfaces with the same opacity. </summary>
<param name="x">Sets the X coordinates of the vertices on X axis.</param>
<param name="y">Sets the Y coordinates of the vertices on Y axis.</param>
<param name="z">Sets the Z coordinates of the vertices on Z axis.</param>
<param name="value">Sets the 4th dimension (value) of the vertices.</param>
<param name="Name">Sets the trace name. The trace name appear as the legend item and on hover</param>
<param name="ShowLegend">Determines whether or not an item corresponding to this trace is shown in the legend.</param>
<param name="Opacity">Sets the opactity of the trace</param>
<param name="Text">Sets a text associated with each datum</param>
<param name="MultiText">Sets individual text for each datum</param>
<param name="ColorScale">Sets the colorscale</param>
<param name="ShowScale">Whether or not to show the colorbar/colorscale</param>
<param name="ColorBar">Sets the colorbar</param>
<param name="IsoMin">Sets the minimum boundary for iso-surface plot.</param>
<param name="IsoMax">Sets the maximum boundary for iso-surface plot.</param>
<param name="Caps">Sets the caps (color-coded surfaces on the sides of the visualization domain)</param>
<param name="Slices">Adds Slices through the volume</param>
<param name="Surface">Sets the surface.</param>
<param name="CameraProjectionType">Sets the camera projection type of this trace.</param>
<param name="Camera">Sets the camera of this trace.</param>
<param name="UseDefaults">If set to false, ignore the global default settings set in `Defaults`</param>
argument y: float seq
<summary> Creates a isosurface plot to visualize the volume of a 3D shape. An isosurface is a surface that represents points of a constant value (e.g. pressure, temperature, velocity, density) within a volume of space. Draws isosurfaces between iso-min and iso-max values with coordinates given by four 1-dimensional arrays containing the `value`, `x`, `y` and `z` of every vertex of a uniform or non-uniform 3-D grid. Horizontal or vertical slices, caps as well as spaceframe between iso-min and iso-max values could also be drawn using this trace. This plot is very similar to the `Volume` plot. However it shows all surfaces with the same opacity. </summary>
<param name="x">Sets the X coordinates of the vertices on X axis.</param>
<param name="y">Sets the Y coordinates of the vertices on Y axis.</param>
<param name="z">Sets the Z coordinates of the vertices on Z axis.</param>
<param name="value">Sets the 4th dimension (value) of the vertices.</param>
<param name="Name">Sets the trace name. The trace name appear as the legend item and on hover</param>
<param name="ShowLegend">Determines whether or not an item corresponding to this trace is shown in the legend.</param>
<param name="Opacity">Sets the opactity of the trace</param>
<param name="Text">Sets a text associated with each datum</param>
<param name="MultiText">Sets individual text for each datum</param>
<param name="ColorScale">Sets the colorscale</param>
<param name="ShowScale">Whether or not to show the colorbar/colorscale</param>
<param name="ColorBar">Sets the colorbar</param>
<param name="IsoMin">Sets the minimum boundary for iso-surface plot.</param>
<param name="IsoMax">Sets the maximum boundary for iso-surface plot.</param>
<param name="Caps">Sets the caps (color-coded surfaces on the sides of the visualization domain)</param>
<param name="Slices">Adds Slices through the volume</param>
<param name="Surface">Sets the surface.</param>
<param name="CameraProjectionType">Sets the camera projection type of this trace.</param>
<param name="Camera">Sets the camera of this trace.</param>
<param name="UseDefaults">If set to false, ignore the global default settings set in `Defaults`</param>
argument z: float seq
<summary> Creates a isosurface plot to visualize the volume of a 3D shape. An isosurface is a surface that represents points of a constant value (e.g. pressure, temperature, velocity, density) within a volume of space. Draws isosurfaces between iso-min and iso-max values with coordinates given by four 1-dimensional arrays containing the `value`, `x`, `y` and `z` of every vertex of a uniform or non-uniform 3-D grid. Horizontal or vertical slices, caps as well as spaceframe between iso-min and iso-max values could also be drawn using this trace. This plot is very similar to the `Volume` plot. However it shows all surfaces with the same opacity. </summary>
<param name="x">Sets the X coordinates of the vertices on X axis.</param>
<param name="y">Sets the Y coordinates of the vertices on Y axis.</param>
<param name="z">Sets the Z coordinates of the vertices on Z axis.</param>
<param name="value">Sets the 4th dimension (value) of the vertices.</param>
<param name="Name">Sets the trace name. The trace name appear as the legend item and on hover</param>
<param name="ShowLegend">Determines whether or not an item corresponding to this trace is shown in the legend.</param>
<param name="Opacity">Sets the opactity of the trace</param>
<param name="Text">Sets a text associated with each datum</param>
<param name="MultiText">Sets individual text for each datum</param>
<param name="ColorScale">Sets the colorscale</param>
<param name="ShowScale">Whether or not to show the colorbar/colorscale</param>
<param name="ColorBar">Sets the colorbar</param>
<param name="IsoMin">Sets the minimum boundary for iso-surface plot.</param>
<param name="IsoMax">Sets the maximum boundary for iso-surface plot.</param>
<param name="Caps">Sets the caps (color-coded surfaces on the sides of the visualization domain)</param>
<param name="Slices">Adds Slices through the volume</param>
<param name="Surface">Sets the surface.</param>
<param name="CameraProjectionType">Sets the camera projection type of this trace.</param>
<param name="Camera">Sets the camera of this trace.</param>
<param name="UseDefaults">If set to false, ignore the global default settings set in `Defaults`</param>
Multiple items
type Caps = inherit DynamicObj new: unit -> Caps static member init: ?X: CapFill * ?Y: CapFill * ?Z: CapFill -> Caps static member style: ?X: CapFill * ?Y: CapFill * ?Z: CapFill -> (Caps -> Caps)

--------------------
new: unit -> Caps
static member Caps.init: ?X: CapFill * ?Y: CapFill * ?Z: CapFill -> Caps
argument X: CapFill option
Multiple items
type CapFill = inherit DynamicObj new: unit -> CapFill static member init: ?Fill: float * ?Show: bool -> CapFill static member style: ?Fill: float * ?Show: bool -> (CapFill -> CapFill)

--------------------
new: unit -> CapFill
static member CapFill.init: ?Fill: float * ?Show: bool -> CapFill
argument Y: CapFill option
Multiple items
type Surface = inherit DynamicObj new: unit -> Surface static member init: ?Count: int * ?Fill: float * ?Pattern: SurfacePattern * ?Show: bool -> Surface static member style: ?Count: int * ?Fill: float * ?Pattern: SurfacePattern * ?Show: bool -> (Surface -> Surface)

--------------------
new: unit -> Surface
static member Surface.init: ?Count: int * ?Fill: float * ?Pattern: StyleParam.SurfacePattern * ?Show: bool -> Surface
type GenericChart = | Chart of data: Trace * layout: Layout * config: Config * displayOpts: DisplayOptions | MultiChart of data: Trace list * layout: Layout * config: Config * displayOpts: DisplayOptions static member addConfig: config: Config -> gChart: GenericChart -> GenericChart static member addDisplayOptions: displayOpts: DisplayOptions -> gChart: GenericChart -> GenericChart static member addLayout: layout: Layout -> gChart: GenericChart -> GenericChart static member combine: gCharts: GenericChart seq -> GenericChart static member countTrace: gChart: GenericChart -> int static member existsTrace: predicate: (Trace -> bool) -> gChart: GenericChart -> bool static member fromChartDTO: dto: ChartDTO -> GenericChart static member fromFigure: fig: Figure -> GenericChart static member getConfig: gChart: GenericChart -> Config static member getDisplayOptions: gChart: GenericChart -> DisplayOptions ...
<summary> The central type that gets created by all Chart constructors is GenericChart, which itself represents either a single chart or a multi chart (as a Discriminate Union type). A GenericChart consists of four top level objects: Trace (multiple of those in the case of a MultiChart), Layout, Config, and DisplayOptions. - `Trace` is in principle the representation of a dataset on a chart, including for example the data itself, color and shape of the visualization, etc. - `Layout` is everything of the chart that is not dataset specific - e.g. the shape and style of axes, the chart title, etc. - `Config` is an object that configures high level properties of the chart like making all chart elements editable or the tool bar on top - `DisplayOptions` is an object that contains meta information about how the html document that contains the chart. </summary>
static member GenericChart.toChartHTML: gChart: GenericChart -> string

Type something to start searching.