Skip to Content.
Sympa Menu

texmacs-users - Re: [TeXmacs] imbedding plots generated by maxima

Subject: mailing-list for TeXmacs Users

List archive

Re: [TeXmacs] imbedding plots generated by maxima


Chronological Thread 
  • From: "Khadga Karki" <address@hidden>
  • To: address@hidden
  • Subject: Re: [TeXmacs] imbedding plots generated by maxima
  • Date: Sun, 16 Aug 2009 13:40:32 +0200 (CEST)
  • Importance: Normal

Hi (let me say) bytecolor,

Many thanks. It works. The only problem was that the ps file always got
saved to my home directory no matter where I started the program from. I
made little changes to the script to fix that problem. May be this is just
a system specific problem. I am using Debian lenny. I have attached the
tampered version of the script.
Any way I am wondering what those control characters do? I just started
using texmacs and maxima and am not familiar with such nifty tricks.

And Paul, perhaps you could adapt the script for R so that you don't have
to keep on importing the figures each time you make them.

cheers,
Khadga

> Hi Khadga,
>
> I had no clue how to use the batch command. Thanks for the info ;)
>
> I created ~/.maxima. I put maxima-init.mac and texmacs.mac there. Then
in
> maxima-init.mac I have the single statement (load "texmacs.mac"). This
keeps me from mucking around with files in /usr.
>
> The problem is the ^B and ^E strings you see in the maxima code I
posted.
> Those are control characters. A single character each, not the two
characters ^ and B. I should have mentioned that. I sometimes assume too
much. I have attached the file texmacs.mac, with the controls characters
embedded. If that doesn't work you can use emacs or some other editor
that
> allows you to enter control characters. In emacs you type C-q then C-b
or
> C-e for the characters.
>
> At least it's finding the .ps file. I did mention this is a quick hack,
no? ;)
>
> --
> bytecolor (S. Edward Dolan)
>
>
> --- On Sat, 8/15/09, Khadga Karki <address@hidden> wrote:
>
>> From: Khadga Karki <address@hidden>
>> Subject: [TeXmacs] imbedding plots generated by maxima
>> To: address@hidden
>> Date: Saturday, August 15, 2009, 4:35 PM
>> Hi,
>> I copied the code to a file name tmplot2d.mac and put in
>> the folder
>> /usr/share/maxima/.../draw/ and issued the command
>> 'batch (tmplot2d)' from maxima to load the function.
>> Then I used the function to make plots.
>> The code works in producing the ps file. But the ps file
>> gets printed in
>> the document rather than being embedded as figure.
>> Did I do it the right way?
>> Khadga
>> > Hello Paul and Khadga,
>> >
>> > Is this the correct thread for this? hrm...
>> >
>> > I'm the curious type, so I looked into this. Before
>> you read any further,
>> > this will not work on Windows.
>> >
>> > Gnuplot works because the session is sending commands
>> directly to Gnuplot,
>> > telling it to write to a .ps, as Paul mentioned. The
>> Gnuplot session then
>> > sends that .ps back to TeXmacs.
>> >
>> > A Maxima session, on the other hand, is talking to
>> Gnuplot `through'
>> > Maxima. You can tell Maxima to write to a .ps:
>> >
>> > plot2d(sin(x), [x, -5, 5], [gnuplot_term, ps]);
>> >
>> > This will write to ~/maxplot.ps by default on my
>> Ubuntu box. But afaik,
>> > the Maxima session has nothing coded to recognize this
>> and send the .ps
>> > back to TeXmacs.
>> >
>> > So, I wrote a Maxima .mac file that does this. It
>> defines tmplot2d() that
>> > behaves just as Maxima plot2d(). The difference is, it
>> automatically
>> > appends [gnuplot_term, ps] after you hit Return. It
>> then sends the .ps
>> > back to TeXmacs.
>> >
>> > It's a quick hack no doubt, but here is the code for
>> texmacs.mac if you
>> > are interested. Hope the leading whitespace is
>> retained.
>> >
>> > /*
>> > * Return a string:
>> > *   PREFIX -> list items separated
>> by SEP -> POSTFIX
>> > */
>> > join_items(prefix, lst, postfix, sep) := (
>> >     len : length(newargs),
>> >     outstr : prefix,
>> >     for i:1 thru len do
>> >     if equal(i, 1) then
>> >         
>>    outstr : sconcat(outstr, newargs[i])
>> >     else
>> >         
>>    outstr : sconcat(outstr, sep,
>> newargs[i]),
>> >     sconcat(outstr, postfix)
>> > )$
>> >
>> > /*
>> >  * Append [gnuplot_term, ps] to a plot2d()
>> command.
>> >  * Output will be to maxplot.ps, by default.
>> >  * This file is fed, along with control
>> characters, back to TeXmacs,
>> >  * ala tm_gnuplot.
>> >  *
>> >  * Can you say `kludge'? I knew that you could.
>> >  */
>> > tmplot2d([args]) := (
>> >     newargs : append(args,
>> [[gnuplot_term, ps]]),
>> >     apply(plot2d, newargs),
>> >     ttyoff : true,
>> >     system("echo -n ^B; \
>> >         
>>    echo -n verbatim:; \
>> >         
>>    echo -n ^B; \
>> >         
>>    echo -n ps:; \
>> >         
>>    cat maxplot.ps; \
>> >         
>>    echo -n ^E; \
>> >         
>>    echo; \
>> >             rm
>> -f maxplot.ps"),
>> >     ttyoff : false,
>> >     /*join_items("plot2d(",
>> newargs, ")")*/
>> >     join_items("plot2d(", newargs,
>> ")", ", ")
>> > )$
>> >
>> > --
>> > bytecolor (S. Edward Dolan)
>> >
>> >
>> >
>> >
>> >
>
>
>


Attachment: texmacs.mac
Description: Binary data




Archive powered by MHonArc 2.6.19.

Top of Page