-
Notifications
You must be signed in to change notification settings - Fork 56
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
[Feature Request] Surface fitting for simple data, and example that shows the surface in plotly #309
Comments
Do you just want to have some kind of regression or just a smoothed interpolation of each point? |
Hi, thanks for the reply, to be honest just looking for any particular solutions, I have a certain amount of data which I want tto plot a surface for, the surface points should not stray away from the data set I have to interpolation like the thin plate spline seem to match my data the best but Ive also managed to replicate in 2d each dimension using tanh or arctan curves. So a F# solution of any sort would suffice for me. F# is th eeasy bits its just figuring out how from samples really. |
If regression is a really close match to my input data I could use that too, but only if the surface is only ever higher than my plotted points, and not by very much. |
@7sharp9 if you just want to visualize your data and do not care about the fit function that creates the surface, you can just use As i do not know how your data looks like, here is a example that contains some boilerplate to generate some 2D data that also visualizes the points from the input across the surface: //---------------------- Generate linearly spaced vector ----------------------
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))
//---------------------- Create example data ----------------------
let size = 100
let x = linspace (-2. * Math.PI, 2. * Math.PI, size) // 100 evenly spaced samples between -2π and 2π
let y = linspace (-2. * Math.PI, 2. * Math.PI, size) // 100 evenly spaced samples between -2π and 2π
let f x y = -(5. * x / (x ** 2. + y ** 2. + 1.)) // function to generate z based on x and y: f(x,y) = -(5 * x / (x^2 + y^2 + 1))
let xyz = Array.init size (fun i -> Array.init size (fun j -> x.[j], y.[i], f x.[j] y.[i])) |> Array.concat // generate x,y,z triplets for point plot
let zArray = Array.init size (fun i -> Array.init size (fun j -> f x.[j] y.[i])) // generate z values for surface plot
[
Chart.Point3D(xyz, Marker = Marker.init(Size = 1, Color = Color.fromString "blue"))
Chart.Surface(zData = z, X = x, Y = y)
]
|> Chart.combine |
Thanks @kMutagene I'm a little slow to respond but thanks for that, I've ended up using Matlab for a lot of my stuff as it has been quick to generate. I'm mainly using a scatter plot of data and then using thin plate interpolation to produce a surface. The surface is then used to create increments over the scatter data, which will be used in C++. I'm getting Matlab to produce C++ code of the interpolated data points. If I had enough time I would try to implement this in F# but its tricky finding the time! |
I want to produce a surface from a combination of data currently in 3 axis, I am using matlab to produce a thin plate spline model and also poly44 and wondered if there are any options to do this with this lib?
Describe the solution you'd like
I would like a sample that generates a surface fit for data in 3 axis and produces a Plotly ploy showing the surface and the original data scattered on top.
Describe alternatives you've considered
Matlab/Python examples are easy to google but I can include one if needed.
The text was updated successfully, but these errors were encountered: