3
$\begingroup$

I have this DATA points:

{{0., 0., 0.117237}, {0.125, 0.0721688, 0.0185109}, {0.125, 0.216506, 
  0.08128}, {0.25, 0., 0.08128}, {0.25, 0.288675, 0.0215464}, {0.25, 
  0.433013, 0.0978551}, {0.375, 0.0721688, 0.0215464}, {0.375, 
  0.216506, 0.0796793}, {0.375, 0.505181, 0.0215464}, {0.375, 
  0.649519, 0.08128}, {0.5, 0., 0.0978551}, {0.5, 0.433013, 
  0.0796793}, {0.5, 0.721688, 0.0185109}, {0.5, 0.866025, 
  0.117237}, {0.625, 0.0721688, 0.0215464}, {0.625, 0.216506, 
  0.0796793}, {0.625, 0.505181, 0.0215464}, {0.625, 0.649519, 
  0.08128}, {0.75, 0., 0.08128}, {0.75, 0.288675, 0.0215464}, {0.75, 
  0.433013, 0.0978551}, {0.875, 0.0721688, 0.0185109}, {0.875, 
  0.216506, 0.08128}, {1., 0., 0.117237}}

that I want to make a density plot. Using high orders of Interpolation does not give an accurated result. I'm trying to do something like this

enter image description here

I've tried to use ListDensityPlot and change the parameters InterpolationOrder -> 1 and MaxPlotPoints -> 100. The result is as follows

enter image description here

As you may notice the result is not exactly the same, but I wish reach the same aspects, with all black around the triangle.

$\endgroup$

1 Answer 1

5
$\begingroup$
data = Import["https://pastebin.com/raw/k0tWUDBD"];

Construct a WeightedData object using the first two columns of data as values and the last column as weights:

wd = WeightedData[data[[All, ;; 2]], data[[All, -1]]];

Use wd with SmoothDensityHistogram:

SmoothDensityHistogram[wd, .05, 
  ColorFunction -> GrayLevel,
  AspectRatio -> All, 
  PlotRange -> All, 
  Frame -> False]

enter image description here

Play with second argument (bandwidth) to get the desired picture.

$\endgroup$
3
  • $\begingroup$ I had some trouble to plot the whole image. What you suggest? $\endgroup$ Jan 7, 2022 at 19:51
  • $\begingroup$ Because of -> General::stop: Further output of Part::pkspec1 will be suppressed during this calculation. Some points are not appearing $\endgroup$ Jan 7, 2022 at 20:34
  • 1
    $\begingroup$ I Think SetAccuracy[data[[All , ;;2]],2] solved the problem $\endgroup$ Jan 8, 2022 at 13:42

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.