patchGNU TeXmacs - Patches: patch #3133, Revisited octave plot interface

 
 

You are not allowed to post comments on this tracker with your current authentication level.

patch #3133: Revisited octave plot interface

Submitter:  None
Submitted:  Tue 15 Jun 2004 08:22:02 AM UTC
   
 
Category:  Plugins Action:  Apply
Privacy:  Public Assigned to:  None
Originator Email:  -email is unavailable- Open/Closed:  Open
Release:  1.3.7 Fixed Release: 
Stable: 

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

Matteo Bertini <matteo99>
Thu 17 Jun 2004 10:59:32 AM UTC, comment #2: 

Ops... my patch has problems with other kind of plots tha use directly _plt2??_.m
Perhaps it is still better to move the gplot redirect upper in the function call tree to avoid multiple plots problems.

Best regards,
Matteo Bertini

Matteo Bertini <matteo99>
Tue 15 Jun 2004 08:29:08 AM UTC, comment #1: 

Following files can be removed, the are called inside _plt_ and so the output is correctly redirected to TeXmacs even using original octave sources.

src/plugins/octave/octave/plot/__errplot__.m
src/plugins/octave/octave/plot/__plt2mm__.m
src/plugins/octave/octave/plot/__plt2mv__.m
src/plugins/octave/octave/plot/__plt2ss__.m
src/plugins/octave/octave/plot/__plt2vm__.m
src/plugins/octave/octave/plot/__plt2vv__.m

Matteo Bertini <matteo99>
Tue 15 Jun 2004 08:22:02 AM UTC, original submission:  

I have seen that a multiple plot in octave like:
plot(x1,";x1;",x2,";x2;")
results in 2 images, the first with x1 and the second with both.

I have moved the texmacs path up in the general _plt_ function, so it works now for all childs without the need to patch them.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #7555:  __tmplot__.m added by None (1KiB - text/x-objcsrc - Utility TeXmacs plot function)
file #7554:  __plt__.m added by None (3KiB - text/x-objcsrc - Main octave plot function, TeXmacs patched)
file #7553:  octave_plot.diffs added by None (5KiB - application/octet-stream - Diffs to contour.m and mesh.m)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

 

Follow 3 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2004-06-15 None Attached File- Added _tmplot_.m, #3365
2004-06-15 None Attached File- Added _plt_.m, #3364
2004-06-15 None Attached File- Added octave_plot.diffs, #3363

Back to the top

Powered by Savane 3.13-758e.
Corresponding source code