2
$\begingroup$

I have this data and there are some zigzag behaviors around the sharp edges

Ddata = Get["C:\\....\\data.dat"];
ListDensityPlot[Ddata, PlotRange -> {{-1.2, 1.2}, {-1.2, 1.2}, All}, 
  PlotRangePadding -> None, 
 ColorFunction -> (Blend[{Red, Gray, Blue}, Rescale[#, {-3, 3}]] &), 
 ColorFunctionScaling -> False]   

enter image description here

I have two questions:

  1. as you can see the zigzag is located by the yellow arrows. I tried to smooth that using InterpolationOrder -> 5 and MaxPlotPoints -> 400 but did not work. How can I Smooth that?

  2. How can I keep the hexagon shape with the white region When I set InterpolationOrder->0? because this is what I get when doing that

enter image description here

$\endgroup$
3
  • $\begingroup$ What happens if you add PerformanceGoal -> "Quality"? $\endgroup$
    – Moo
    Commented Jan 7, 2022 at 19:22
  • 1
    $\begingroup$ @Moo, I tried that too, but gives the same output $\endgroup$
    – MMA13
    Commented Jan 7, 2022 at 19:25
  • $\begingroup$ Click the link in the question (the word data) $\endgroup$
    – MMA13
    Commented Jan 7, 2022 at 20:44

1 Answer 1

4
$\begingroup$

Your color function combined with ColorFunctionScaling -> False seem to be interfering with the built-in interpolation of the ListDensityPlot[].

The solution below uses a built-in color gradient and puts the Z range limits in PlotRange and uses ClippingStyle-> Automatic to fill in the regions who's values are outside of the Z range.

ListDensityPlot[Ddata, 
 PlotRange -> {{-1.2, 1.2}, {-1.2, 1.2}, {-3, 3}}, 
 PlotRangePadding -> None, 
 ColorFunction -> ColorData[{"ThermometerColors", "Reverse"}], 
 ClippingStyle -> Automatic]

enter image description here

Here it is with your original colors:

ListDensityPlot[Ddata, 
 PlotRange -> {{-1.2, 1.2}, {-1.2, 1.2}, {-3, 3}}, 
 PlotRangePadding -> None, 
 ColorFunction -> (Blend[{Red, Gray, Blue}, #] &), 
 ClippingStyle -> Automatic]

enter image description here

$\endgroup$
2
  • $\begingroup$ that is great. Any idea how to solve the second question, please? $\endgroup$
    – MMA13
    Commented Jan 8, 2022 at 0:16
  • 1
    $\begingroup$ Interpolation order zero will make the edges jagged again but If that's what you need I can take a look tomorrow. Maybe some combination of the RegionFunction option and hexRegion = ConvexHullRegion[Ddata] and $\endgroup$ Commented Jan 8, 2022 at 8:05

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.