home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / COLOR.DI$ / COLORMAP.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  2.1 KB  |  58 lines

  1. function map = colormap(arg)
  2. %COLORMAP Set the color look-up table.
  3. %     COLORMAP(MAP) sets the current figure's colormap to MAP.
  4. %     COLORMAP('default') sets the current figure's colormap to
  5. %    the root's default, whose factory setting is HSV.
  6. %     MAP = COLORMAP retrieves the current colormap. The values
  7. %    are in the range from 0 to 1.
  8. %
  9. %    A color map matrix may have any number of rows, but it must have
  10. %    exactly 3 columns.  Each row is interpreted as a color, with the
  11. %    first element specifying the intensity of red light, the second 
  12. %    blue, and the third green.  Color intensity can be specified on the
  13. %    interval 0.0 to 1.0.
  14. %     For example, [0 0 0] is black, [1 1 1] is white, 
  15. %     [1 0 0] is pure red, [.5 .5 .5] is gray, and
  16. %    [127/255 1 212/255] is aquamarine.
  17. %     
  18. %     Graphics objects that use pseudocolor  -- SURFACE and PATCH objects,
  19. %    which are created by the functions MESH, SURF, and PCOLOR -- map
  20. %     a color matrix, C, whose values are in the range [Cmin, Cmax],
  21. %     to an array of indices, k, in the range [1, m].
  22. %     The values of Cmin and Cmax are either min(min(C)) and max(max(C)),
  23. %     or are specified by CAXIS.  The mapping is linear, with Cmin
  24. %     mapping to index 1 and Cmax mapping to index m.  The indices are
  25. %     then used with the colormap to determine the color associated
  26. %     with each matrix element.  See CAXIS for details.
  27. %     Type HELP COLOR to see a number of useful colormaps.
  28. %
  29. %    COLORMAP is an M-file that sets the Colormap property of the current
  30. %    figure.
  31. %
  32. %     See also COLOR, HSV, CAXIS, SPINMAP, BRIGHTEN, RGBPLOT, FIGURE.
  33.  
  34. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  35.  
  36. if (nargin == 0)
  37.     map = get(gcf, 'Colormap');
  38.     return
  39. end
  40. if isstr(arg)
  41.     if strcmp(arg,'default')
  42.         set(gcf,'Colormap','default');
  43.         return
  44.     else
  45.         arg = eval(arg);
  46.     end
  47. end
  48. if ~isempty(arg)
  49.     if (size(arg,2) ~= 3)
  50.         error('Colormap must have 3 columns: [R,G,B].');
  51.     end
  52.     if min(min(arg)) < 0 | max(max(arg)) > 1
  53.         error('Colormap must have values in [0,1].')
  54.     end
  55. end
  56. set(gcf, 'Colormap', arg);
  57.