Question: saving plots to a file (from inside a function)

Hello:

I am trying to be able to solve my plots into a file programatically (not via right click/export).


when I do this:

p:=plot(sin(x));display(p);

plotsetup(default):  #optional - just to be sure start off at default.
plotsetup(ps, plotoutput="test.eps", plotoptions=`portrait,noborder`);
display(p);

things work ok

BUT.. doint this:

p:=plot(sin(x));display(p);

savePlot:=proc(v_p, v_fileName)  # lets define a function to do this
  plotsetup(ps, plotoutput=v_fileName, plotoptions=`portrait,noborder`);
  display(v_p);   # also tried without "display"
  plotsetup(default):
end proc;
proc(v_p, v_fileName)  ...  end;

savePlot(p, "test.eps");

is broken - no file test.eps gets written to disk.

is this a bug? does anyone have a workour (other than doing this outside of function)?

thank you.

Please Wait...