I am making a contour plot out of a list of values of the form {{x1,y1,f1},{x2,y2,f2},…} I want to plot this on a log log scale so I specify ScalingFunctions -> {"Log", "Log"} but I also want to only plot the data over a particular region of the range. Such as above the line specified by: RegionFunction -> (#2 > -# + 1 &) but these won't work together.

So here is a basic example that highlights the problem:

list = Flatten[Table[{i, j, i^2 - j^2}, {i, 0, 1, 0.01}, {j, 0, 1, 0.01}], 1];
ListContourPlot[list, ScalingFunctions -> {"Log", "Log"}]
ListContourPlot[list, RegionFunction -> (#2 > -# + 1 &)]
ListContourPlot[list, ScalingFunctions -> {"Log", "Log"}, 
      RegionFunction -> (#2 > -# + 1 &)]

The first two work but when I try to combine RegionFunction and ScalingFunctions it doesn't work.

Thoughts on a workaround? Thanks!

  • $\begingroup$ Please, give at least some example for list to test with. $\endgroup$ – Henrik Schumacher Nov 1 '18 at 17:28
  • 1
    $\begingroup$ I just did. Good point. $\endgroup$ – E. Nerney Nov 1 '18 at 17:55
  • $\begingroup$ does RegionFunction -> (Exp[#2]+Exp[#]>1 &) give the desired region or do you want the triangle as in the second plot? $\endgroup$ – kglr Nov 1 '18 at 18:05
  • $\begingroup$ I want the last line of code to work. So just the upper triangular region and scaled log log axes. $\endgroup$ – E. Nerney Nov 1 '18 at 18:09
  • $\begingroup$ It really doesn't matter what region I am referring to though. The point is RegionFunction and ScalingFunctions don't work together. $\endgroup$ – E. Nerney Nov 1 '18 at 18:15

Per kglr's comment, the following produces

g = ListContourPlot[list, 
 ScalingFunctions -> {"Log", "Log"}, 
 RegionFunction -> (Exp[#2] + Exp[#1] > 1 &)

enter image description here

so ScalingFunctions and RegionFunction do work together. Indeed, this contour plot should correspond to the logarithmized version of this

 RegionFunction -> (#2 + #1 > 1 &)

In fact, the logarithmically scaled axes lie to you as can be seen by plotting the contour plot g from above together with the unit disk:


enter image description here

Hence your code

ListContourPlot[list, ScalingFunctions -> {"Log", "Log"}, 
 RegionFunction -> (#2 > -#1 + 1 &)]

because there are no points in list that, after logarithmical rescaling fullfil the condition of RegionFunction.

  • $\begingroup$ Thanks this makes sense now. $\endgroup$ – E. Nerney Nov 1 '18 at 19:16
  • $\begingroup$ Well the sum of to exponentials is always positive, right? With, e.g., RegionFunction -> (Exp[#2] + Exp[-45*(#1/4)^(-0.4229)] > 20 &), you will see a difference. $\endgroup$ – Henrik Schumacher Nov 7 '18 at 22:50
  • $\begingroup$ I deleted my comment above about doing this for above a power law region because I figured it out. For the region above y=45(x/4)^(-0.4229) with ScalingFunctions -> {"Log", "Log"} I actually wanted RegionFunction -> (Exp[#2] - 45*(Exp[#]/4)^(-0.4299)] > 0 &) Very strange.....but I figured it out. Like why do you leave everything the same except the rescaled variables? Also why isn't it 10^(#2) instead of Exp[#2] when the axes are base 10 scaled it seems? Either way I made it work. Thanks for your response though! $\endgroup$ – E. Nerney Nov 7 '18 at 22:59
  • $\begingroup$ Good point. But standard Log-Scaling is with respect to Log. Only the tick marks are to base 10. You can also use ScalingFunctions -> {"Log10", "Log10"}. If you prefer a Log10-Log10 plot. $\endgroup$ – Henrik Schumacher Nov 7 '18 at 23:16
  • $\begingroup$ Oh, ok well that part makes sense then at least. Thanks! $\endgroup$ – E. Nerney Nov 7 '18 at 23:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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