I have an expression with lots of variables, and I would like to make several plots of the expression, where the axis in each is a different variable. The idea is to put them side by side inside a Manipulate
structure that lets me move around the values of the rest. But I am having problems with order of evaluation, because sometimes the value of x
gets substituted in before Plot
gets a hold of it.
Here is an example. Let's say my expression is x^y
. The following code works perfectly, and is an example of what I am trying to make more modular:
Manipulate[
GraphicsRow[{
Plot[x^y, {x, .1, 2}, AxesLabel -> {"x"}] ,
Plot[x^y, {y, .1, 2}, AxesLabel -> {"y"}] }],
{x, .1, 2}, {y, .1, 2}]
It works, I believe, because the first Plot
looks for its variable x
and scopes the x
in x^y
as local (something like FE`x$$1010
before Manipulate
gets to substitute in the value from the slider. (Is this right?)
Now, in my application, the expressions to be plotted, and the variables and range against which to plot, are more dynamic. Here is my failed attempt at this:
With[{exprsToPlot = {x^y, x^y},
plotRangeSpecs = {{x, .1, 2}, {y, .1, 2}}},
Manipulate[
MapThread[Plot, {exprsToPlot, plotRangeSpecs}],
{x, .1, 2}, {y, .1, 2} ] ]
(I left out the AxesLabel
because I'd first like to get the basic piece to work, though if any solution-writer wants to make that and other plot options work, I'd be impressed.)
I also tried using Thread
instead of MapThread
, which actually mostly works, while throwing errors:
With[{exprsToPlot = {x^y, x^y},
plotRangeSpecs = {{x, .1, 2}, {y, .1, 2}}},
Manipulate[ Thread[Plot[exprsToPlot, plotRangeSpecs]]
I think the solution involves holding the variable to plot (x
and y
respectively) but not the others, I haven't been able to implement this. I tried to make my own version of MapThread
with the attribute HoldAll
, but that won't do because the variables other than the x-axis ones (y
and x
, respectively) do need to be substituted for their values from the sliders before Plot
gets a hold of them.
It would be ideal if the solution could take named arguments in a list too, as in setting plotLabels={"title1", "title2"}
, and having plotLabels
be another list argument passed to Plot
. But Thread
isn't set up to deal with named arguments, as far as I know.
Also, in my example I plotted the same x^y
in both figures, but in general the entries of exprsToPlot
may not be the same.
f(x,y,z)
(3 dimensions). I'd like to use the Manipulate sliders to pick a base point(x0,y0,z0)
and have plots showing what happens to the value off
as the argument is varied in each of several dimensions (perhaps justx
andy
, if those are the only variables of interest). In my application there are more like 10 arguments and I want to see plots of 3 or so of them. $\endgroup$