Search code examples
loopsplotexporthidemaple

Maple: Export a plot in a hidden loop


I have written a Maple script to calculate some functions and then export some properties (coefficients, expectation values, etc.) as plots. The basic layout of the script is this:

printlevel := 2;
A := some_array;
B := some_array_s;
for j from 1 to length(A) do
for i from 1 to length(B) do
#Do calculations and create folders to put the plots in
curfile := example.png;
plotsetup(png, plotoutput = curfile);
plot(x, cn, style=point);
fclose(curfile);
end do;
end do:

The calculations in between are pretty big, so I don't want Maple to show me every step, it will slow things down a lot. That's why I put the colon on the end of the last end do. If I just use a semi-colon (;) it will execute fine and produce plots, but the process is really slow and uses up a lot of memory because it will show me every difficult formula. This is not an option.

Now the problem is that if I use the colon (:) to hide the for-loop output it will not export the plots. I tried putting display() around the plotting command, but that did not work. Just putting colons behind every command in the loops does not work also, because everything will be executed that way. Is there any way I can hide the output of the for loops and still export the plots?


Solution

  • Just use print(plot(...)) in the loop.