3
$\begingroup$

How to get the following ContourPlot

ContourPlot[4 (s + i) -  Log[s] +  Log[i], {s, 0, 1}, {i, 0, 1}]

over a non rectangular region? First try

ContourPlot[4 (s + i) - Log[s] + Log[i], 
 Element[{s, i}  ,  {s > 0 && i > 0 && s + i < 1}]]

does not work.

$\endgroup$
1
  • 2
    $\begingroup$ For your first try, wrap the region condition with ImplicitRegion: ContourPlot[4 (s + i) - Log[s] + Log[i], Element[{s, i}, ImplicitRegion[{s > 0 && i > 0 && s + i < 1}, {s, i}]]], but this is considerably slower and disables the refinement option PlotPoints. $\endgroup$ – Michael E2 May 16 at 16:38
6
$\begingroup$

For a region of the form $a \le x \le b$, $f(x) \le y \le g(x)$, one can use

ContourPlot[eqn, {x, a, b}, {y, f[x], g[x]}]

In the OP's case:

ContourPlot[4 (s + i) - Log[s] + Log[i], {s, 0, 1}, {i, 0, 1 - s}]

enter image description here

$\endgroup$
6
$\begingroup$

Try the RegionFunction option:

ContourPlot[4 (s + i) - Log[s] + Log[i], {s, 0, 1}, {i, 0, 1}, 
 RegionFunction -> (#1 + #2 < 1 &)]

enter image description here

$\endgroup$

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.