1
$\begingroup$

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

enter image description here

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.

enter image description here

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

$\endgroup$
8
  • $\begingroup$ I suggest posting your data, or a minimal working example. $\endgroup$ Mar 30, 2016 at 19:59
  • $\begingroup$ What does InterpolationOrder -> 0 give you? $\endgroup$
    – BlacKow
    Mar 30, 2016 at 21:49
  • $\begingroup$ It will make the upper part red all over $\endgroup$
    – Kangning
    Mar 31, 2016 at 2:44
  • $\begingroup$ 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 $\endgroup$
    – Kangning
    Mar 31, 2016 at 2:52
  • $\begingroup$ 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] $\endgroup$ Mar 31, 2016 at 2:58

2 Answers 2

0
$\begingroup$

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 -> Charting`get2DPlotRange@ListDensityPlot[data],
     AspectRatio -> Automatic,
     ColorFunction -> ColorData[{"Rainbow", MinMax@data[[All, 3]]}],
     ColorFunctionScaling -> False] & /@ 
   Reverse[GatherBy[data, #[[3]] == 4. &]]
  ],
 BarLegend[{"Rainbow", MinMax@data[[All, 3]]}]
 ]

enter image description here

$\endgroup$
0
$\begingroup$

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

Surface plot

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?

$\endgroup$
2
  • $\begingroup$ 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? $\endgroup$
    – Kangning
    Mar 31, 2016 at 13:40
  • $\begingroup$ I think @JasonB provided a compact solution for this in his answer. $\endgroup$
    – JimB
    Mar 31, 2016 at 14:56

Your Answer

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

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