Can a procedure return separate plots?

Hi everyone,

Here is a problem that I couldn't solve:

I've written a procedure to perform some tasks, and I want it to plot some results as output, in addition to the equations of those plots (I don't think the details of the procedure are necessary at this stage, but I'll be happy to provide if needed). My problem is: Each procedure can only plot a single picture. I know Maple can plot several graphs in one plot region, but is it possible to do the converse?

For example:

p := proc(x,y)
   plot(x^2, x=0..2);
   plot(y^3, y=-2..2);
end proc():

p(x,y);

will only plot y^3 from -2 to 2, since in Maple, "the result a procedure returns is the value of the last executed statement in the body of the procedure". What if I wanted it to plot both x^2 and y^3, but in separate plot regions?

Thank you in advance for your time.

Ozgur Inal

Create an array of plots

You can put two plots side-by-side or one on top of the other by using an Array. For example:
> plots[display](Array([plot(...), plot(...)]));
The plots[display] help page gives more information about this feature and includes a few examples.

Paulina Chin
Maplesoft

Robert Israel's picture

print

Another way, if you want separate plots rather than an Array of them, is to use print.

For example:

> p := proc()
   print(plot(x^2, x=0..2));
   print(plot(y^3, y=-2..2));
end proc:
> p();

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}