/usr/share/freemat/toolbox/graph/text.m is in freemat-data 4.0-5build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | % TEXT TEXT Add Text Label to Plot
%
% Usage
%
% Adds a text label to the currently active plot. The general
% syntax for it is use is either
%
% text(x,y,'label')
%
% where x and y are both vectors of the same length, in which
% case the text 'label' is added to the current plot at each of the
% coordinates x(i),y(i) (using the current axis to map these to screen
% coordinates). The second form supplies a cell-array of strings
% as the second argument, and allows you to place many labels simultaneously
%
% text(x,y,{'label1','label2',....})
%
% where the number of elements in the cell array must match the size of
% vectors x and y. You can also specify properties for the labels
% via
%
% handles = text(x,y,{labels},properties...)
%
% Copyright (c) 2002-2006 Samit Basu
% Licensed under the GPL
function handles = text(varargin)
if (nargin < 3)
error 'text requires at least three arguments, the x and y location vectors and the strings'
end
xvec = varargin{1};
yvec = varargin{2};
labels = varargin{3};
varargin(1:3) = [];
if (length(xvec) ~= length(yvec))
error 'vectors x and y must be the same length'
end
if (isa(labels,'char'))
labelarray = repmat({labels},[length(xvec),1]);
elseif (iscellstr(labels))
labelarray = labels;
if (length(labelarray) ~= length(xvec))
error 'number of labels much match the length of the x and y vectors'
end
else
error 'labels must be either a single string or a cell array of strings.'
end
if (nargout > 0)
handles = [];
end
for (i=1:numel(xvec))
h = htext('position',[xvec(i),yvec(i)],'string',labelarray{i},varargin{:});
if (nargout > 0)
handles = [handles,h];
end
end
|