0
$\begingroup$

Consider the following input:

temp := c
Manipulate[RegionPlot[True, {a, 0, 1}, {b, 0, temp}], {c, 0, 1}]

I expect to get a region plot with a manipulate slider that I can use to change the domain on the vertical axis. But the slider doesn't do anything and the vertical domain is just stuck at [0,0.0001].

Does anyone know what this isn't working?

$\endgroup$
5
  • 3
    $\begingroup$ You have a scoping problem, because c in temp := c is not the same as the localized c used in Manipulate. I think the cleanest ways is to use Clear[temp]; temp[c_] := c, then Manipulate[RegionPlot[True, {a, 0, 1}, {b, 0, temp[c]}], {c, 0, 1}]. $\endgroup$ Commented Jun 10, 2024 at 13:38
  • $\begingroup$ @Domen thanks. Is there a reason you didn't post this as an answer? Also, would it be possible to explain (or to point to an explanation) why temp:=c and temp[c_]:=c produce different behaviour? I had thought the only difference was one of syntax: the latter allows you to specify the arguments of temp when calling it. $\endgroup$ Commented Jun 11, 2024 at 9:41
  • $\begingroup$ Because it's a common mistake and questions like this appear sporadically here, but I wasn't in a mood to search for an exact duplicate to close the question :) $\endgroup$ Commented Jun 11, 2024 at 10:09
  • 1
    $\begingroup$ Does this answer your question? How are parameters evaluated for a Plot in Manipulate See also section Possible issues in the documentation for Manipulate. $\endgroup$ Commented Jun 11, 2024 at 10:09
  • $\begingroup$ @Domen yes, it does thanks. $\endgroup$ Commented Jun 11, 2024 at 10:35

1 Answer 1

0
$\begingroup$

I think you need to bring temp into the Manipulate, e.g:

Manipulate[
 RegionPlot[True, {a, 0, 1}, {b, 0, temp}],
 {temp, 0.1, 1}]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks, yes. But my problem is that my application temp is not a simple constant but rather a complicated function of c defined elsewhere in the notebook. I don't want to copy the whole thing when it seems like I should be able to refer to the relevant expression by its variable name. $\endgroup$ Commented Jun 10, 2024 at 13:18

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.