view graphics/scat.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents 82075c94eed1
children
line wrap: on
line source
function H=scat(x,varargin)

% SCAT:	2D/3D scatter plot using dots
% Usage: h=scat(x,...)
%
%    x - matrix of 2D or 3D points
%    h - returns handle graphics object
%
% Valid options
%    'perspective'::(0|1)/1 ~'use perspective projection in 3D'
%    'axis'::(0|1)/1 ~'remove axes if 0'
%    'box' ::(0|1)/1 ~'enable/disable axis box'
%    'marker'::string ~'standard matlab marker code'
%    'plotargs'::cell{} ~'extra arguments to plot'
%
% In 3D, sets up axes so that shapes are right.

if isa(x,'data'), x=double(x); end

marker=get(gca,'DefaultLineMarker');
if strcmp(marker,'none'), marker=get(gcf,'DefaultLineMarker'); end
if strcmp(marker,'none'), marker=get(0,'DefaultLineMarker'); end
if strcmp(marker,'none'), marker='+'; end
opts=prefs('perspective',1,'axis',1,'box',1,'marker',marker, ...
	'plotargs',{},varargin{:});
if size(x,2)<=4 && size(x,1)>8, x=x'; end

if isfield(opts,'markersize'), 
	opts.plotargs=[{'MarkerSize',opts.markersize},opts.plotargs]; 
end

if (size(x,1)>=3),
	h=plot3(x(1,:),x(2,:),x(3,:),opts.marker,opts.plotargs{:});
	if opts.perspective, camproj('perspective'); end
	axis equal;
	axis vis3d;
elseif ~isempty(x)
	h=plot(x(1,:),x(2,:),opts.marker,opts.plotargs{:});
else
	h=[];
end

%set(gca,'DrawMode','fast');
%set(gcf,'Renderer','painters');
if (nargout>0), H=h; end

if ~opts.box, box off; else; box on; end
if ~opts.axis, axis off; end