Home > bioelectromagnetism > plot_get_lines.m

plot_get_lines

PURPOSE ^

Get Line Data from Current Figure

SYNOPSIS ^

function [xdata,ydata] = get_lines

DESCRIPTION ^

 Get Line Data from Current Figure

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [xdata,ydata] = get_lines
0002 
0003 % Get Line Data from Current Figure
0004 
0005 % Lines are referenced as axis children, among other
0006 % axis children; so first get all axis children
0007 sibs = get(gca,'Children');
0008 
0009 % Now search axis children for any line types.
0010 % Because the columns of the y data matrix in a plot
0011 % command seem to be reversed in the axis children,
0012 % count down from max sibs to the first sib.
0013 lines = 0;
0014 xdata = [];
0015 ydata = [];
0016 
0017 i = max(size(sibs));
0018 while i >= 1,
0019   if strcmp(get(sibs(i),'Type'),'line')
0020     % Found a line child, but check its size
0021     getline = 1;
0022     if ~isempty(xdata),
0023       if isequal(size(get(sibs(i),'XData').',1),size(xdata,1)),
0024         getline = 1;
0025       else
0026         getline = 0;
0027       end
0028     end
0029     if getline,
0030       % OK, found a line among the axis children.
0031       lines = lines + 1;
0032       datalines(lines) = sibs(i);
0033       
0034       % put line data into a column of data.xdata|data.ydata
0035       xdata(:,lines) = get(sibs(i),'XData').';
0036       ydata(:,lines) = get(sibs(i),'YData').';
0037     end
0038   end
0039   i = i - 1;
0040 end

Generated on Mon 15-Aug-2005 15:36:19 by m2html © 2003