- From: "Khadga Karki" <address@hidden>
- To: address@hidden
- Subject: [TeXmacs] imbedding plots generated by maxima
- Date: Sat, 15 Aug 2009 22:35:34 +0200 (CEST)
- Importance: Normal
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)
>
>
>
>
>
Archive powered by MHonArc 2.6.19.