RegionFunction
is normally good at suppressing points in a plot:
ListPlot3D[Flatten[Table[{x, y, RandomReal[]*(x^2 + y^2)}, {x, -5, 5}, {y, -5, 5}], 1],
RegionFunction -> ((#2 >= #1 && #2 >= -#1) || (#2 <= #1 && #2 <= -#1) &)]
Now consider this data, which is some random numbers over a diamond-shaped domain:
data = {#[[1]], #[[2]], #[[3]]*(#[[1]]^2 + #[[2]]^2)} & /@
({(#[[1]] - #[[2]])/2, (#[[1]] + #[[2]])/2, #[[3]]} & /@
Flatten[Table[{x, y, RandomReal[0.1]}, {x, 0, 5}, {y, 0, 5}], 1]);
ListPlot3D[data, PlotRange -> {0, 5}]
Now let's mirror the data over the x-axis, and note that ListPlot3D
will automatically plot the connecting regions between the two diamonds:
dataMirrored = DeleteDuplicates@Join[data, {#[[1]], -#[[2]], #[[3]]} & /@ data];
ListPlot3D[dataMirrored, PlotRange -> {All, All, {0, 5}}]
Now, it seems RegionFunction
doesn't work - I guess this has something to do with the data taking similar values across the gap:
ListPlot3D[dataMirrored, PlotRange -> {0, 5},
RegionFunction -> ((#2 >= #1 && #2 >= -#1) || (#2 <= #1 && #2 <= -#1) &)]
Even adding a small perturbations to all three coordinates of every point does not completely block this behavior:
ListPlot3D[{#[[1]] + RandomReal[10^-3], #[[2]] + RandomReal[10^-3],
#[[3]] + RandomReal[10^-3]} & /@ dataMirrored, PlotRange -> {0, 5},
RegionFunction -> ((#2 >= #1 && #2 >= -#1) || (#2 <= #1 && #2 <= -#1) &)]
How can I get ListPlot3D
to respect RegionFunction
?