0
$\begingroup$

I solve a PDE of which solution is physically a probability density $p$. Due to the algorithm the result is a $n\times m$-matrix which will be plotted by ListPointPlot3D and colored by a blend like this

f[x_, y_] := Exp[-x^2 - 100 y^2]

ListPointPlot3D[
  Transpose[Table[f[x, y], {x, -3, 3, 0.05}, {y, -3, 3, 0.05}]], 
  ColorFunction -> (Blend[{Green, Yellow, Red}, #3] &), 
  Filling -> Axis, PlotStyle -> PointSize[0], PlotRange -> Full, 
  AxesLabel -> {"x", "y", "p"}, DataRange -> {{-3, 3}, {-3, 3}}
]

ListPointPlot3D

Let's say that there would be an analytical result, so no discretization is required, then this result could be represented with Plot3D:

Plot3D[f[x, y], {x, -3, 3}, {y, -3, 3}, 
  ColorFunction -> (Blend[{Green, Yellow, Red}, #3] &), 
  PlotRange -> Full, AxesLabel -> {"x", "y", "p"}, Mesh -> None, 
  PlotPoints -> 100
]

enter image description here

The appearance of Plot3D is much better. How can i improve the appearance of the ListPointPlot3D so that there are no gaps between the discretized points?

EDIT: ListPlot3D is not an option. Let $m0$ be the data of the solution. E.G.

ListPlot3D[m0, ColorFunction -> (Blend[{Green, Yellow, Red}, #3] &), 
  Filling -> Axis, PlotRange -> Full, Mesh -> None
]

enter image description here

But an ListLinePlot3D has a much better visual outcome in this case.

ListPointPlot3D[m0, 
  ColorFunction -> (Blend[{Green, Yellow, Red}, #3] &), 
  Filling -> Axis, PlotStyle -> PointSize[0], PlotRange -> Full
]

enter image description here

But it is still not perfect. Depending on the ViewPoint (or ViewAngle) one can see gaps or a unsmooth transition.

$\endgroup$
2
  • 1
    $\begingroup$ Try ListPlot3D. $\endgroup$
    – C. E.
    Apr 6 '15 at 20:42
  • $\begingroup$ And PlotPoints-> 100 or the equivalent of increasing the number of $x$ and $y$ points in the iterators. $\endgroup$ Apr 6 '15 at 21:06
1
$\begingroup$

As suggested by @Pickett with minor, cosmetic tweaks:

 f[x_, y_] := Exp[-x^2. - 100. y^2.] + .0000001;

 ListPlot3D[
 Transpose[
     Table[f[x, y], {x, -3, 3, 0.05}, {y, -3, 3, 0.05}]], 
 ColorFunction -> (Blend[{Green, Yellow, Red}, #3] &),
 Filling -> Axis,
 PlotStyle -> PointSize[0],
 PlotRange -> Full,
 AxesLabel -> {"x", "y", "p"},
 DataRange -> {{-3, 3}, {-3, 3}},
 Mesh -> None]

And you mentioned that your function is a probability density. As such, normalize your function first. Alternatively, notice that your function is a MultinormalDistribution:

 Plot3D[
  PDF[MultinormalDistribution[{0, 0}, {{1, 0}, {0, .001}}], 
  {x, y}], 
  {x, -3, 3}, {y, -3, 3},
 PlotRange -> All]
$\endgroup$
6
  • $\begingroup$ In my case, this is not the better solution. I've oversimplified the problem. The matrix is actually a list of $(x,y,p)$-vectors which are on the $(x,y)$-plane dense. You can see an edit to my question. $\endgroup$ Apr 6 '15 at 23:45
  • $\begingroup$ @Drakonomikon The ListPlot3D[m0, ...] solution looks great in version 10.1. But if the $(x, y, p)$ values obey your explicit Exp[ ] equation, then they do obey a MultinormalDistribution, so why not use such a distribution and avoid all your problems? $\endgroup$ Apr 6 '15 at 23:49
  • $\begingroup$ Due to a licensing issue we have not received an update. This will take a few weeks. So i'm still using 10.0.1. Does that really make a difference? $\endgroup$ Apr 6 '15 at 23:52
  • $\begingroup$ The problem is not the Exp[] function. The result of the PDE looks like an exponential-function but it isn't. Using MultinormalDistribution does not change the problem and it is even not possible. $\endgroup$ Apr 7 '15 at 9:41
  • $\begingroup$ @Drakonomikon Did you post a Multinormal distribution (Exp[-ax^2 - by^2]) and then claim that the function you seek to plot isn't such a distribution? $\endgroup$ Apr 7 '15 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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