source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/lightspeed/graphics/color_plot.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

  • Property svn:executable set to *
File size: 1.5 KB
Line 
1function color_plot(x,colors,varargin)
2% COLOR_PLOT    Scatterplot with colored points.
3% color_plot(x) makes a scatterplot of x(:,1) versus x(:,2) with points colored
4% according to quantiles of x(:,3).
5% color_plot(x,n) specifies the number of color quantiles (default 4).
6% color_plot(x,colors) specifies an RGB matrix of colors (the number of rows
7% determines the number of quantiles).  The default is YlGnBu_colors.
8% color_plot(...,'ColorBar',1) adds a color bar with tick marks from the
9% quantile values.
10%
11% Example:
12%   xy = ndgridmat(linspace(-12,12,20),linspace(-12,12,20));
13%   z = sin(sqrt(xy(:,1).^2 + xy(:,2).^2));
14%   color_plot([xy z]);
15%
16% See also YlGnBu_colors.
17
18% Written by Tom Minka and Charles Sutton
19
20args = makestruct(varargin);
21default_args = struct('ColorBar',0);
22args = setfields(default_args,args);
23
24if nargin < 2
25  colors = 4;
26end
27if length(colors) == 1
28  nlevels = colors;
29  colors = YlGnBu_colors(nlevels);
30else
31  nlevels = rows(colors);
32end
33% color groups
34[c,q] = cut_quantile(x(:,3),nlevels);
35for lev = 1:nlevels
36  i = find(c == lev);
37  plot(x(i,1),x(i,2),'o','Color',colors(lev,:),'MarkerFaceColor',colors(lev,:));
38  hold on
39end
40hold off
41
42colormap(colors);
43
44if args.ColorBar
45  caxis ([0,1]);
46 
47  cTickLbls = cell(numel(q), 1);
48  for i = 1:length(q)
49      cTickLbls{i} = num2str(q(i), '%11.2g');
50  end
51 
52  colorbar('YTick', linspace(0,1,nlevels+1), 'YTickLabel', cTickLbls);
53end
54
55set(gca,'Color','none')
Note: See TracBrowser for help on using the repository browser.