[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Texmacs-dev] modified octave plot
From: |
Matteo Bertini |
Subject: |
[Texmacs-dev] modified octave plot |
Date: |
Thu, 03 Feb 2005 15:08:02 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041214 Thunderbird/1.0 Mnenhy/0.7 |
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 <address@hidden>
#derived from Michael Graffam <address@hidden> 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 <address@hidden>
#derived from Michael Graffam <address@hidden> 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Texmacs-dev] modified octave plot,
Matteo Bertini <=