createcolormap

버전 0.2 (1.74 MB) 작성자: Takuya Miyashita
This function allows to create colormap Nx3 array (RGB) with an arbitrary combination of colors.
다운로드 수: 192
업데이트 날짜: 2021/10/9

createcolormap.m

View createcolormap on File Exchange
This function allows to create colormap Nx3 array (RGB) with an arbitrary combination of colors. RGB values between the specified colors will be smoothly connected by linear interpolation.

Example

cmap = createcolormap(C);
cmap = createcolormap(n,C);
cmap = createcolormap(colorA, colorB);
cmap = createcolormap(n, colorA, colorB);
cmap = createcolormap(colorA, colorB, colorC, colorD, ...);
cmap = createcolormap(n, colorA, colorB, colorC, colorD, ...);

where n is the number of segments for the output color scheme, and C is the RGB matrix of color junctions.

Usage

  • blue-white-red (polar)

    b = [0,0,1];
    w = [1,1,1];
    r = [1,0,0];
    
    bwr = createcolormap(b,w,r); % 256x3 array
    
    colormap(bwr)
    colorbar

    If you want to use dark blue and red colors, try below:

    b = [0.0,0.0,0.5];
    w = [1.0,1.0,1.0];
    r = [0.5,0.0,0.0];
    
    bwr = createcolormap(b,w,r); % 256x3 array
    
    colormap(bwr)
    colorbar

    To create a more discrete color structure, input the number of elements in the first argument as shown below.

    bwr = createcolormap(16,b,w,r); % 16x3 array 
  • more complicated combination

    colorA = [0.0,1.0,0.0];
    colorB = [1.0,0.5,0.5];
    colorC = [0.5,0.5,0.5];
    colorD = [1.0,1.0,0.0];
    
    cmap = createcolormap(64,colorA,colorB,colorC,colorD); % 64x3 array
    
    surf(peaks); 
    colormap(cmap);
    colorbar;
  • RGB matrix

    cmap = createcolormap(rand(10,3)); % 10 random colors
    
    surf(peaks);
    colormap(cmap);
    colorbar;

License

MIT

Author

Takuya Miyashita
Disaster Prevention Research Institute, Kyoto University

Update

v0.1 2021/10/01
v0.2 2021/10/09

인용 양식

Takuya Miyashita (2024). createcolormap (https://github.com/hydrocoast/createcolormap/releases/tag/v0.2), GitHub. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2021b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
태그 태그 추가

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
0.2

See release notes for this release on GitHub: https://github.com/hydrocoast/createcolormap/releases/tag/v0.2

0.1

이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.
이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.