# How to show no data (white background) with ListDensityPlot instead of copying exteme values of data?

I have a list of experimental (x,y,f) data, e.g. I can generate similar data with this:

Fitness[{x_, y_}] := (x - 1)^2 + 10 (x^2 - y)^2;
ListDensityPlot[Flatten[#, 1] &@ Table[{x, y, Fitness[{x, y}]}, {x, -1, 1.5, 0.1}, {y, -1, 1.5,
0.1}], InterpolationOrder -> 0]


How to show more range in this ListDensityPlot to illustrate absence of data (of course with white backgroung style)? I mean that if you just try to increase range with PlotRange -> {{-5, 5}, Automatic, Automatic}, you will see smth like this

This picture illustrates that WM instead of showing white background in regions without data interpolates data or, idk, tries to copy extreme values of data and shows this values in no data regions.

How to show white background in regions where I don't have experimental data?

• Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. Commented Jul 27, 2021 at 14:51

You can use RegionFunction to limit where the data is plotted. For example, to plot just for x values between -1 and 1.5:

ListDensityPlot[Flatten[#, 1] &@
Table[{x, y, Fitness[{x, y}]}, {x, -1, 1.5, 0.1}, {y, -1, 1.5,
0.1}], InterpolationOrder -> 0,
PlotRange -> {{-5, 5}, Automatic, Automatic},
RegionFunction -> Function[{x, y, f}, -1 <= x <= 1.5]]


If you want the full range of your function for x from -1 to 1.5, change the PlotRange to {{-5, 5}, Automatic, All}

• Thank you! This is the best way! Commented Jul 28, 2021 at 10:10

I think the easiest way would be to use PlotPaddingRange inside Show just like this:

Show[ListDensityPlot[
Flatten[#, 1] &@
Table[{x, y, Fitness[{x, y}]}, {x, -1, 1.5, 0.1}, {y, -1, 1.5,
0.1}], InterpolationOrder -> 0],
PlotRangePadding -> {{4, 3.5}, {0, 0}}]


And the result (please, do not mind small white artifacts) would be: