2
$\begingroup$

I have some data that needs to be represented using the function ListDensityPlot, for example :

data = {{1, 1, 1}, {2, 3, 2}, {1, 4, 3}, {5, 1, 4}, {6, 4, 5}}
ListDensityPlot[data]

And this gives :

enter image description here

However, if we show the meshes using this code :

data = {{1, 1, 1}, {2, 3, 2}, {1, 4, 3}, {5, 1, 4}, {6, 4, 5}}
ListDensityPlot[data, Mesh -> All]

It shows this :

enter image description here

How can i specify ListDensityPlot to only Plot within the data point, and not plot the region delimited by the triangle {1,1},{2,3},{1,4} (the one on the left side} ?

Thanks in advance

$\endgroup$
2
  • $\begingroup$ Why is that triangle different than the other triangles where data is given at all of the vertices? $\endgroup$
    – mjw
    Apr 8, 2019 at 16:10
  • $\begingroup$ because listdensityplot gives me a a polygon with 4 edges when the result is 5 edges. Same goes for my actual data, i have an n sided polygon when i actually want something like n+10 $\endgroup$ Apr 8, 2019 at 19:30

1 Answer 1

3
$\begingroup$

Use the option RegionFunction

data = {{1, 1, 1}, {2, 3, 2}, {1, 4, 3}, {5, 1, 4}, {6, 4, 5}};

ListDensityPlot[data, Mesh -> All,
 RegionFunction ->
  (Not[{#1, #2} \[Element] Triangle[{{1, 1}, {2, 3}, {1, 4}}]] &)]

enter image description here

$\endgroup$
1
  • $\begingroup$ thank you very much ! it does exactly what i need it to do ! $\endgroup$ Apr 8, 2019 at 19: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.