Octave 3.0 plot arrows

View: New views
1 Messages — Rating Filter:   Alert me  

Octave 3.0 plot arrows

by color_guru :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I am using Octave 3.0.0 on a windows xp with gnuplot as graphics backend. I have a list of x,y values in a file named "from.dat" and "to.dat". I need to plot arrows with the tail at "from" and the head at "to".

I was able to do this pre 3.0.0 using the function arrow.m pasted below. But is not working anymore in 3.0.0 and giving the following error.

parse error:

  syntax error

>>> __gnuplot_set__ arrow 1 from 0.000000,0.000000 to 0.020000,-0.200000

Any help will be greatly appreciated. Thanks in Advance!

Rohit

function arrow(strt, endmat, minxy, maxxy)

if(nargin<2)
        error("arrow: Number of input parameters must be 2");
endif

[nr_strt, nc_strt] = size(strt);
[nr_end, nc_end]   = size(endmat);

if(nr_strt!=nr_end)
        error("arrow: Input arguments must have equal number of rows");
endif

if(nc_strt!=2 || nc_end!=nc_strt)
        error("arrow: Input matrices must have 2 columns");
endif

minx = min([min(strt(:,1)) min(endmat(:,1))]);
miny = min([min(strt(:,2)) min(endmat(:,2))]);
maxx = max([max(strt(:,1)) max(endmat(:,1))]);
maxy = max([max(strt(:,2)) max(endmat(:,2))]);

__gnuplot_set__ nokey;
if(nargin==4)
        eval(sprintf("__gnuplot_set__ xrange [%f:%f] ",minxy(1),maxxy(1)));
        eval(sprintf("__gnuplot_set__ yrange [%f:%f] ",minxy(2),maxxy(2)));
else
        eval(sprintf("__gnuplot_set__ xrange [%f:%f] ",minx,maxx));
        eval(sprintf("__gnuplot_set__ yrange [%f:%f] ",miny,maxy));
endif

for i=1:nr_strt
        eval(sprintf("__gnuplot_set__ arrow %d from %f,%f to %f,%f\n",i,strt(i,1),strt(i,2),endmat(i,1),endmat(i,2)));
endfor
plot((minx+maxx)/2,(miny+maxy)/2);

endfunction