Thu 10 Feb 2005 03:01:46 PM UTC, comment #3:
An update...
Hi all!
I've modified the octave plot plugin a little, now it works with all
commands because simply replot-to-TeXmacs at the end. I'm posting it
here because I'm not very confident with diff tools and patches... :-(
Usage:
octave] plot(...), hist(...), what-plot-command-you-like(...) <------ no
output
octave] tmreplot; <------ output the figure
You have to modify the tm-start.oct file to discard output by default:
#####################################
gset output "/dev/null"; #discard output by default
gset size 1,0.6; #I like it more then .5, .5
#####################################
This is the function, mainly taken from the present tm-octave plugin:
- it redirect the output on a temp-file and
- then imports it in TeXmacs,
- finally it restores the output to /dev/null removing temp-file.
# cat /usr/share/TeXmacs/plugins/octave/octave/plot/tmreplot.m
#####################################
#Octave plots inside TeXmacs
#Created 3 Feb 2005
#Author Matteo Bertini <matteob@naufraghi.net>
#derived from Michael Graffam <mgraffam@mathlab.sunysb.edu> work
function tmreplot ()
if (length(getenv("TEXMACS_PATH"))>0)
# we are inside TeXmacs
gset output "/tmp/tmplot.eps";
replot;
P=[2;112;115;58]; # P= "\002ps:"
g=fopen("/tmp/tmplot.eps", "rb");
while (g==-1)
sleep(1);
g=fopen("/tmp/tmplot.eps", "rb");
endwhile
while (!feof(g))
f=fread(g,2048);
if (length(f))
P=[P;f];
endif
endwhile
fclose(g);
P=[P;5];
disp(sprintf("%cverbatim:",2));
disp(setstr(P'));
system("rm -f /tmp/tmplot.eps");
gset output "/dev/null";
else
usage("Use from TeXmacs");
endif
endfunction
#####################################
----------------------------- option two --------------------------------
You can easily restore the automatic output of plot with:
# cat /usr/share/TeXmacs/plugins/octave/octave/plot/plot.m
#####################################
#Octave plots inside TeXmacs
#Created 3 Feb 2005
#Author Matteo Bertini <matteob@naufraghi.net>
#derived from Michael Graffam <mgraffam@mathlab.sunysb.edu> work
function res = plot (varargin)
_plt_("plot", varargin{:});
if (nargout == 0)
tmreplot;
endif
res = 0;
endfunction
#####################################
This litle hack provides that:
octave] plot([1,2,3,4]); #has output
instead
octave] p = plot([1,2,3,4]); #is silent
octave] tmreplot; <------ output the figure
For other plotting functions the problem is that they don't have a
double wrapper like _plt_ so it is easy to get out of sync with the
official Octave sources (like it is now), so I think it is better the
tmreplot-at-the-end way.
----------- known problems --------------
- some resource goes away plotting twice, one time to null the other to
TeXmacs.
- sometime hitting RETURN after a plot returns [?], usually a retry and
then it is ok.
Expecting comments or suggestions,
Matteo Bertini
|