maxima plot options gnuplot_out_file



Thanks,
seems like there may not be a way to pass a function thats to be evaluated
as the
parameter to gnuplot, for now i settled with having a little program watch
my work directory and rename each image as soon as it created. Not
efficient but until i figure out some way of adding hooks to maxima's
gnupot interface, this will suffice.



On Sat, Jul 20, 2013 at 12:09 PM, Jaime Villate <villate at fe.up.pt> wrote:

> On 19-07-2013 22:53, jiun bookworm wrote:
>
>> Im curious to find out whether there is a way to set the gnuplot_out_file
>> variable to some function that returns a unique string , currently i have a
>> line in my .maxima/maxima-init.mac  like this:
>>
>> set_plot_option ([gnuplot_out_file,"./tmp/**myplot.jpeg"])$
>>
>> is it possible to change that to a function that generates a new unique
>> name each time? i'd like not to have to  type a name for an image file, so
>> its some unique random string for each plot image whenever i plot, this
>> important when i plot more than one graph at a time.
>> regards
>>
> Hi,
> it is easy to define a function that will return different file names each
> time you call it:
>
> concat("./tmp/", string(gensym("myplot")), ".jpeg")
>
> and this also has the extra feature that the plots will be enumerated
> sequentially. The problem is that it will not work as you want it when
> placed inside your set_plot_option command; plot2d and plot3d regard the
> options given as symbol names and strings, and not as expressions that must
> be evaluated.
>
> However, you could do something like this: define a function that
> generates different filenames the way you want them:
>
> plot_file():= ['gnuplot_out_file,concat("./**
> tmp/",string(gensym("plot")),"**.png")]$
>
> and then add that function at the end of each plot2d command you use; for
> example,
>
> plot2d (x^2, [x,-2,2], [gnuplot_term,png], plot_file());
>
> in this example the plot was saved in the file ./tmp/plot971.png
> If you don't want to have to write that extra part every time, you can
> also create a function:
>
> mypngplot2d([args]):=apply(**plot2d,append(args,[[gnuplot_**
> term,png],plot_file()]))$
>
> mypngplot2d(x^3,[x,-2,2]);
>
> and the plot of x^3 was saved into the file ./tmp/plot972.png. You can
> still type plot2d(x^3,[x,-2,2]) to see the same plot on your screen.
>
> Notice that:
> 1) The "./tmp/..." filenames you want to use will fail if the current
> directory where Maxima is running does not have a a subdirectory named tmp.
> 2) I used PNG, rather than JPEG because it is a bad idea to save a plot in
> JPEG format.
>
> I hope that helps,
> Jaime
>
>