Skip to content

Issue in generating data equivalent to numpy mgrid #151

Closed
@usmanzafar289

Description

@usmanzafar289

Description

Facing issue in converting the example such as https://plotly.com/python/3d-volume-plots/. Found no function which give data equivalent to data generated by numpy mgrid. Tried to find way but did not work.

open System
open Plotly.NET 

             
let N = 50
let rnd = System.Random()

let mirroredXAxis =
    Axis.LinearAxis.init(
        Showspikes = false,
        Backgroundcolor ="rgb(229, 236, 246)",
        Showbackground=true
    )

let mirroredLogYAxis = 
    Axis.LinearAxis.init(
        Showspikes = false,
        Backgroundcolor ="rgb(229, 236, 246)",
        Showbackground=true
    )
let mirroredZAxis =
    Axis.LinearAxis.init(
        Showspikes = false,
        Backgroundcolor ="rgb(229, 236, 246)",
        Showbackground=true
    )

let margin =Margin.init(Left =10.0, Bottom=10.0,Top =10.0, Right  = 20.0 )
let layout = Layout.init(Width= 700.,  Margin=margin)

let x = [-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-2.666666666666667;-2.666666666666667;-2.666666666666667;-2.666666666666667;-2.666666666666667;-2.666666666666667;-2.666666666666667;-2.666666666666667;-2.666666666666667;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0]
let y =[-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-2.666666666666667;-2.666666666666667;-2.666666666666667;-2.666666666666667;-2.666666666666667;-2.666666666666667;-2.666666666666667;-2.666666666666667;-2.666666666666667;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0]
let z =[-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-8.0;-2.666666666666667;-2.666666666666667;-2.666666666666667;-2.666666666666667;-2.666666666666667;-2.666666666666667;-2.666666666666667;-2.666666666666667;-2.666666666666667;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0;8.0]
let value =[0.00015530955861889912;0.004994853639720335;0.004994853639720164;0.00015530955861889912;0.004994853639720335;0.005865742088537837;0.005865742088537603;0.004994853639720335;0.004994853639720164;0.005865742088537603;0.0058657420885372515;0.004994853639720164;004994853639720335;0.004994853639720164;0.005865742088537603;0.005865]

let findAllIndices predicate =
    Array.indexed
    >> Array.filter (snd >> predicate)
    >> Array.map fst

       
let volume3d =
        Trace3d.initVolume (fun volume3d ->
            volume3d?x <- x
            volume3d?y <-y
            volume3d?z <-z
            volume3d?value <-x
            volume3d?isomin <-0.1
            volume3d?isomax <-0.8
            volume3d?opacity<-0.5
            volume3d?color <- "lightpink"
            volume3d
            )     
        |> GenericChart.ofTraceObject
        |> Chart.withLayout layout

3d_volume

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions