주요 콘텐츠

colormaplist

사용 가능한 컬러맵 나열

R2025a 이후

    설명

    cmaps = colormaplist는 사용 가능한 컬러맵 목록을 m×1 string형 배열로 반환합니다.

    예제

    예제

    모두 축소

    컬러맵 목록을 반환합니다.

    cmaps = colormaplist
    cmaps = 
    
      21×1 string array
    
        "parula"
        "turbo"
        "hsv"
        "hot"
        "cool"
        "spring"
        "summer"
        "autumn"
        "winter"
        "gray"
        ...

    특정 컬러맵에 정의된 RGB 3색을 반환하는 함수를 만듭니다.

    컬러맵 목록을 반환합니다.

    cmaps = colormaplist
    cmaps = 
    
      21×1 string array
    
        "parula"
        "turbo"
        "hsv"
        "hot"
        "cool"
        "spring"
        "summer"
        "autumn"
        "winter"
        "gray"
        ...

    str2func를 사용하여 turbo 컬러맵의 처음 n개의 RGB 3색을 반환하는 함수를 정의합니다.

    cmapFcn = str2func(cmaps(2))
    cmapFcn =
    
      function_handle with value:
    
        @turbo

    cmapFcn을 사용하여 turbo의 처음 5개의 RGB 3색을 나열합니다.

    cmapFcn(5)
    ans =
    
        0.1900    0.0718    0.2322
        0.1602    0.7332    0.9252
        0.6384    0.9910    0.2365
        0.9853    0.5018    0.1324
        0.4796    0.0158    0.0106

    plotwithcolormaps 함수는 axes 객체를 만들고 좌표축에 곡면을 플로팅합니다. 또한 이 함수는 목록 상자도 만들고 colormaplist를 호출한 결과를 사용하여 목록을 채웁니다.

    function plotwithcolormaps
        f = uifigure;
        ax = axes(f,Units="pixels",Position=[180 100 500 400]);
        cmaps = colormaplist;
        uilistbox(f,Position=[750 200 120 320],Items=cmaps,...
            ValueChangedFcn=@applycmap);
        surf(ax,peaks)
    
        function applycmap(src,~)
            colormap(src.Parent,src.Value)
        end
    end

    plotwithcolormaps를 저장하고 실행합니다. 목록 상자에서 옵션을 선택하여 그래프의 컬러맵을 변경합니다.

    plotwithcolormaps

    Surface plot and a list box with selectable colormaps

    버전 내역

    R2025a에 개발됨