This question already has an answer here:

As it says, I am using ListDensityPlot (in 10.4), where the data is only defined on a dumbbell shaped region.

As shown below

ListDensityPlot does the following:

ListDenistyPlot result

which clearly works on the convex hull. To test, I added a regionFunction to the Plot, and draw the outline in red. So how do I only draw on the inside of the dumbbell?


marked as duplicate by Jason B., bbgodfrey, MarcoB, Sascha, corey979 Jan 20 '17 at 8:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 3
    $\begingroup$ Use RegionFunction with whatever generated your first plot to restrict the plot to your domain of interest. But then, where is the code for generating your region? $\endgroup$ – J. M. is away Dec 20 '16 at 12:50
  • $\begingroup$ insidedumb[i_, j_, r_, o_, d_] := (i - r - o)^2 + j^2 <= r^2 \[Or] (i + r + o)^2 + j^2 <= r^2 \[Or] (-o <= i <= o \[And] -d <= j <= d) $\endgroup$ – Niels Walet Dec 20 '16 at 13:36
  • $\begingroup$ Also, I did add this as a RegionFunction option to my LstDensityPlot. No effect! $\endgroup$ – Niels Walet Dec 20 '16 at 13:39
  • 3
    $\begingroup$ You need to provide a minimal working example. That is; the code that defines your dumbbell region, a set of data, and the ListDensityPlot code that creates the plot. $\endgroup$ – Edmund Dec 20 '16 at 13:46
  • 1
    $\begingroup$ Unless code is given to show how it's different, then I would mark this as a duplicate of this post. The answer posted there should work perfectly for this example as well. $\endgroup$ – Jason B. Dec 20 '16 at 15:34

OK, A first partial answer can be found from deep in the documentation (under Options->Mesh): "The entire mesh for irregular data is a Delaunay triangulation". My mesh is of course not irregular; my boundary is, and what I see is a Delaunay triangulation of my mesh. The surprise is that using the RegionFunction still shows the whole mesh, including parts outside the region.

A solution is to overlay the plot with the negation of the function that tests whether points are inside RegionPlot[\[Not] in[i, j], {i, -xm, xm}, {j, -ym, ym}, ColorFunction -> Function[{x, y, z}, White], BoundaryStyle->None].

That works, by just using Show.



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