2
$\begingroup$

I have generated a 3D plot using a specialized plotting function (in this case, SmoothHistogram3D). I would like to extract the function shown in this plot (even if it ends up being something like an InterpolatingFunction), so that I can find values, take derivatives, plot slices, etc. Is there any way to do this without manually generating the function outside of the specialized plotting function? Alternatively, is there a way to stop the specialized plotting function after it calculates the InterpolatingFunction (or equivalent), but before it plots it?

$\endgroup$

1 Answer 1

3
$\begingroup$

SmoothHistogram3D is based on SmoothKernelDistribution, which wrapped in PDF will give you your function:

data = RandomVariate[BinormalDistribution[.75], 10];
dis = SmoothKernelDistribution[data];
Plot3D[PDF[dis, {x, y}], {x, -3, 3}, {y, -3, 3}, 
   PlotRange -> All, 
   MeshFunctions -> {#3 &}, 
   ColorFunction -> "Rainbow"]

For other cases use Interpolation to get InterpolatingFunction.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.