diff private/scatc.m @ 0:be936975f254

Initial check in.
author samer
date Wed, 01 Feb 2012 14:06:37 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/private/scatc.m	Wed Feb 01 14:06:37 2012 +0000
@@ -0,0 +1,43 @@
+function h=scatc(x,C,S,varargin)
+% scatc - 2 or 3D scatter plot with colours and sizes
+%
+% scatc :: [[N,E]] ~'N points in E space', [[N]]~'colours' -> handle.
+% scatc :: 
+%    [[N,E]] ~'N points in E space', 
+%    [[N]]   ~'colours', 
+%    [[N]] | real  ~'array of sizes or single marker size'
+% -> handle.
+%
+% If E<3, does 2D scatter, otherwise, does 3D scatter plot.
+% Draws filled circles. 
+
+if size(x,2)<=4 && size(x,1)>4, x=x'; end
+if nargin<3 || isempty(S),
+	% use default marker size
+	S=get(gca,'DefaultLineMarkerSize').^2; 
+elseif length(S)==1,
+	S=S*ones(size(x,2),1);
+end
+
+if size(x,1)<3,
+	h=scatter(x(1,:),x(2,:),S,C);
+else
+	h=scatter3(x(1,:),x(2,:),x(3,:),S,C);
+end
+
+set(h, ...
+	'MarkerFaceColor','flat', ...
+	'MarkerEdgeColor','k', ...
+	'LineWidth',0.2, ...
+	varargin{:});
+
+axis equal;
+if size(x,1)>2
+	axis vis3d;
+	axis off;
+	set(gca,'DrawMode','fast');
+	set(gca,'Projection','perspective');
+else
+	box on;
+	% axis off;
+end