]> Creatis software - CreaPhase.git/blob - octave_packages/nan-2.5.5/gscatter.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / nan-2.5.5 / gscatter.m
1 function [h] = gscatter(x,y,group,clr,sym,siz,doleg,xname,yname)
2 % GSCATTER scatter plot of groups 
3 %
4 %  gscatter(x,y,group)
5 %  gscatter(x,y,group,clr,sym,siz)
6 %  gscatter(x,y,group,clr,sym,siz,doleg)
7 %  gscatter(x,y,group,clr,sym,siz,doleg,xname,yname)
8 %  h = gscatter(...) 
9 %
10 %  x,y, group:  vectors with equal length 
11 %  clf:         color vector, default 'bgrcmyk'
12 %  sym:         symbol, default '.'
13 %  siz:         size of Marker
14 %  doleg:  'on' (default) shows legend, 'off' turns of legend 
15 %  xname, yname: name of axis
16 %
17 %
18 % see also: ecdf, cdfplot
19 %
20 % References: 
21
22 %       $Id$
23 %       Copyright (C) 2009 by Alois Schloegl <alois.schloegl@gmail.com>
24 %       This function is part of the NaN-toolbox
25 %       http://pub.ist.ac.at/~schloegl/matlab/NaN/
26
27 % This program is free software; you can redistribute it and/or
28 % modify it under the terms of the GNU General Public License
29 % as published by the Free Software Foundation; either version 3
30 % of the  License, or (at your option) any later version.
31
32 % This program is distributed in the hope that it will be useful,
33 % but WITHOUT ANY WARRANTY; without even the implied warranty of
34 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
35 % GNU General Public License for more details.
36
37 % You should have received a copy of the GNU General Public License
38 % along with this program; if not, write to the Free Software
39 % Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
40
41 [b,i,j] = unique(group); 
42
43 if nargin<3
44         help gscatter; 
45         error('invalid number of arguments;')
46 end;
47 if nargin<4
48         clr = [];
49 end
50 if nargin<5
51         sym = [];
52 end
53 if nargin<6
54         siz = [];
55 end
56 if nargin<7
57         doleg = [];
58 end
59 if nargin<8
60         xname = [];
61 end
62 if nargin<9
63         yname = [];
64 end; 
65 if isempty(clr), clr='bgrcmyk'; end; 
66 if isempty(sym), sym='.'; end; 
67 if isempty(doleg), doleg='on'; end; 
68
69 for k=1:length(b);
70         %ix = find(k==j);
71         c = clr(mod(k-1,length(clr))+1); 
72         s = sym(mod(k-1,length(sym))+1); 
73         hh(k) = plot(x(k==j),y(k==j),[c,s]);
74         if ~isempty(siz)        
75                 z = siz(mod(k-1,length(siz))+1); 
76                 set(hh(k),'MarkerSize',z);
77         end     
78         hold on; 
79 end; 
80 hold off; 
81
82 if ~strcmpi(doleg,'off')
83         if isnumeric(b)
84                 b=num2str(b(:));
85         end;    
86         legend(b);
87 end;
88 if ~isempty(xname)
89         xlabel(xname); 
90 end; 
91 if ~isempty(yname)
92         ylabel(yname); 
93 end; 
94         
95 if nargout>0,
96         h = hh; 
97 end;
98