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$ Commented May 16, 2021 at 16:38

2 Answers 2

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$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.