Home > bioelectromagnetism > crosshair_set.m

crosshair_set

PURPOSE ^

SYNOPSIS ^

function [lines] = crosshair_set(x,y,percent)

DESCRIPTION ^

 crosshair_set - place a crosshair on current plot at x,y position

 [lines] = crosshair_set(x,y,percent)

 x,y are the location of the cross (default at 0,0).  The x value
 specifies the intercept of a line with the x axis, the line is
 parallel with the y axis.  The y value specifies the intercept of a
 line with the yaxis, the line is parallel with the xaxis.

 lines.x,lines.y are handles to the crosshair lines

 The length of the lines is a 'percent' of the axis range; this value
 ranges from 0 to 1, the default is 1

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [lines] = crosshair_set(x,y,percent)
0002 %
0003 % crosshair_set - place a crosshair on current plot at x,y position
0004 %
0005 % [lines] = crosshair_set(x,y,percent)
0006 %
0007 % x,y are the location of the cross (default at 0,0).  The x value
0008 % specifies the intercept of a line with the x axis, the line is
0009 % parallel with the y axis.  The y value specifies the intercept of a
0010 % line with the yaxis, the line is parallel with the xaxis.
0011 %
0012 % lines.x,lines.y are handles to the crosshair lines
0013 %
0014 % The length of the lines is a 'percent' of the axis range; this value
0015 % ranges from 0 to 1, the default is 1
0016 %
0017 
0018 if ~exist('x','var'), x = 0; end
0019 if ~exist('y','var'), y = 0; end
0020 if ~exist('percent','var'), percent = 1; end
0021 
0022 if isempty(x), x = 0; end
0023 if isempty(y), y = 0; end
0024 if isempty(percent), percent = 1; end
0025 
0026 x_rng = get(gca,'Xlim') .* percent;
0027 y_rng = get(gca,'Ylim') .* percent;
0028 
0029 % should check whether x,y are within x_rng, y_rng
0030 
0031 lines.x = line([x,x],[y_rng(1),y_rng(2)]);
0032 set(lines.x,'Color','k');
0033 
0034 lines.y = line([x_rng(1) x_rng(2)],[y y]);
0035 set(lines.y,'Color','k');
0036 
0037 return

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