1 function [h] = gscatter(x,y,group,clr,sym,siz,doleg,xname,yname)
2 % GSCATTER scatter plot of groups
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)
10 % x,y, group: vectors with equal length
11 % clf: color vector, default 'bgrcmyk'
12 % sym: symbol, default '.'
14 % doleg: 'on' (default) shows legend, 'off' turns of legend
15 % xname, yname: name of axis
18 % see also: ecdf, cdfplot
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/
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.
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.
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.
41 [b,i,j] = unique(group);
45 error('invalid number of arguments;')
65 if isempty(clr), clr='bgrcmyk'; end;
66 if isempty(sym), sym='.'; end;
67 if isempty(doleg), doleg='on'; end;
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]);
75 z = siz(mod(k-1,length(siz))+1);
76 set(hh(k),'MarkerSize',z);
82 if ~strcmpi(doleg,'off')