Skip to content

Issue in generating data equivalent to numpy mgrid #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
usmanzafar289 opened this issue Aug 25, 2021 · 1 comment
Closed

Issue in generating data equivalent to numpy mgrid #151

usmanzafar289 opened this issue Aug 25, 2021 · 1 comment

Comments

@usmanzafar289
Copy link

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

@kMutagene
Copy link
Collaborator

please wait until the next release is live today and take a look at the code samples posted in the recently merged PR here for emulating mgrid and creating all of the missing 3D charts: #125 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants