ListDensityPlot boundary is extrapolated

I have a solution of a finite element analysis and I have a list of data {{x,y,a}....} where x, y are the coordinates and a is the value to be plotted. The geometry is half of a tooth like this

but when I used

ListDensityPlot[data,
PlotLegends -> Automatic, AspectRatio -> Automatic, ColorFunction -> "Rainbow",
InterpolationOrder -> 1
]


to plot, the boundary is blurred. it seems to be extrapolated.

Anyone knows how to fix this to show the boundary?

the data can be found here: [https://drive.google.com/file/d/0BxRSTZpaT9wrcVI5enVVMl9laGs/view?usp=sharing][3] I made it a .nb file and two plots of InterpolationOrder of 0 and 1

• I suggest posting your data, or a minimal working example. Mar 30, 2016 at 19:59
• What does InterpolationOrder -> 0 give you? Mar 30, 2016 at 21:49
• It will make the upper part red all over Mar 31, 2016 at 2:44
• the data can be found here: [drive.google.com/file/d/0BxRSTZpaT9wrcVI5enVVMl9laGs/… I made it a .nb file and two plots of InterpolationOrder of 0 and 1 Mar 31, 2016 at 2:52
• your data seems blurred to me, try ListPlot[data[[All, 3]]] or data[[All, 3]] = Floor@data[[All, 3]]; ListDensityPlot[data, PlotLegends -> Automatic, AspectRatio -> Automatic, ColorFunction -> "Rainbow", InterpolationOrder -> 1] Mar 31, 2016 at 2:58

As Jim Baldwin points out, the blurriness is to be expected because ListDensityPlot is trying to interpolate between the two regions. But what you are trying to do is show density plots of two different regions together using a unified color scheme.

So the solution is to actually make 2 different density plots and lay them over top of each other, then you will have a nice boundary between them.

Legended[
Show[ListDensityPlot[#,
PlotRange -> Chartingget2DPlotRange@ListDensityPlot[data],
AspectRatio -> Automatic,
ColorFunction -> ColorData[{"Rainbow", MinMax@data[[All, 3]]}],
ColorFunctionScaling -> False] & /@
Reverse[GatherBy[data, #[[3]] == 4. &]]
],
BarLegend[{"Rainbow", MinMax@data[[All, 3]]}]
]


This is just an extended comment/question to show the results of ListPointPlot3D[data]`:

Are you talking about the blurriness at the edge of the dark object at the top and the associated edge of the surface on the bottom? If so, isn't the blurriness expected because of the interpolation between the border of the upper dark surface and the lower surface? If the blurriness is somewhere else, would you point out where it is?

• You are right. the blurriness of the upper dark surface is not expected. I just don't want it to be extrapolated at the boundary. is there a way to "define" a boundary from the data? Mar 31, 2016 at 13:40
• I think @JasonB provided a compact solution for this in his answer.
– JimB
Mar 31, 2016 at 14:56