I have a contour plot which I make using ListContourPlot from discrete data, which looks like this.

contour plot generated from data

The data live on grid points that are shown in light blue, and function values are not defined under the red curve; the corresponding entries are Nulls. I believe that the diagonal 'line' running across the bottom right is an artifact of the interpolation carried out by ListContourPlot, and I would appreciate some help with removing that as well. I would like to exclude the region under the red line from my plot using RegionFunction, but I am not able to do this.

The code I am using to generate the plot shown here is as follows:

  Transpose@{\[Gamma]Plist10, CD2Pset10} /. {{x_, y_}, z_} -> {x, y, 
     z}, PlotTheme -> "Monochrome", PlotLegends -> Automatic, 
  ImageSize -> Medium, Mesh -> None, ClippingStyle -> Automatic, 
  RegionFunction -> 
   Function[{\[Gamma], P}, 
    Abs[P] >= Evaluate@typeCexistencefunc[\[Gamma]]]], 
 Plot[typeCexistencefunc[x], {x, 0, 0.5}, PlotStyle -> Red],ListPlot[{\[Gamma]Plist10}]]

The function typeCexistencefunc is an InterpolatingFunction, and you can see that it works as expected since the red line does indeed appear. However, the RegionFunction part does not work.

If I use a different function to define my region, such as a straight line or the equation of a circle, it works as expected.

If I do not use the ClippingStyle option, I get something even more strange:

enter image description here

Note that the only Nulls in my data are those under the red curve. The values in the top right region of the plot are very low, and in the bottom left region of the plot they are very high.

edited to add: I have also tried using an unstructured interpolation function using

ff = Interpolation[
  Transpose@{\[Gamma]Plist10, CD2Pset10} /. {{x_, y_}, z_} -> {x, y, 
ContourPlot[ff[\[Gamma], P], {\[Gamma], 0, 0.5}, {P, 0, 1.5}, 
 ClippingStyle -> Automatic, PlotTheme -> "Monochrome"]

but this doesn't work as well as a ListContourPlot does. The result looks like this: using interpolation function

TL;DR: RegionFunction doesn't seem to work well with ListContourPlot when using an InterpolatingFunction to define the region of interest.

  • $\begingroup$ Have you tried to create an unstructured Interpolation function to begin was with? $\endgroup$
    – user21
    Commented Feb 14, 2023 at 5:02
  • $\begingroup$ You mean a 2D interpolation function? yes, I have tried Interpolation[ Transpose@{\[Gamma]Plist10, CD2Pset10} /. {{x_, y_}, z_} -> {x, y, z}] and tried putting that in a ContourPlot. The results is not much better -- I'll add it to the question $\endgroup$ Commented Feb 14, 2023 at 15:40

1 Answer 1


One solution to this problem seems to be to add Filling -> Axis, FillingStyle -> White to my plot of the red line. This is a satisfactory workaround, but I will leave this question open in case someone has a solution to the underlying problem.


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.