Main Content

colormap

현재 컬러맵 보기 및 설정

설명

컬러맵 설정

예제

colormap map은 현재 Figure의 컬러맵을 미리 정의되어 있는 지정된 컬러맵으로 설정합니다. 예를 들어 colormap hot은 컬러맵을 hot으로 설정합니다.

Figure에 대한 컬러맵을 설정한 경우, Figure의 좌표축과 차트는 동일한 컬러맵을 사용합니다. 새 컬러맵은 현재 컬러맵과 길이(색 개수)가 동일합니다. 이 구문을 사용할 때는 컬러맵에 사용자 지정 길이를 지정할 수 없습니다. 컬러맵에 대한 자세한 내용은 세부 정보 섹션을 참조하십시오.

예제

colormap(map)은 현재 Figure의 컬러맵을 map으로 지정된 컬러맵으로 설정합니다.

예제

colormap(target,map)은 현재 Figure가 아니라 target으로 지정된 Figure, 좌표축 또는 독립형 시각화의 컬러맵을 설정합니다.

cmap = colormap(___)은 컬러맵을 설정한 다음, RGB 3색으로 구성된 3열 행렬로 반환합니다. 위에 열거된 괄호를 사용한 구문과 함께 cmap를 출력 인수로 지정합니다.

현재 컬러맵 가져오기

예제

cmap = colormap은 현재 Figure의 컬러맵을 RGB 3색의 3열 행렬로 반환합니다.

예제

cmap = colormap(target)target으로 지정된 Figure, 좌표축 또는 독립형 시각화의 컬러맵을 반환합니다.

예제

모두 축소

곡면 플롯을 만들고 컬러맵을 winter로 설정합니다.

surf(peaks)
colormap winter

Figure contains an axes object. The axes object contains an object of type surface.

먼저, 현재 Figure의 컬러맵을 summer로 변경합니다.

surf(peaks)
colormap summer

Figure contains an axes object. The axes object contains an object of type surface.

이제 컬러맵을 다시 시스템의 디폴트 값으로 설정합니다. 다른 디폴트 값을 지정하지 않은 경우 디폴트 컬러맵은 parula입니다.

colormap default

Figure contains an axes object. The axes object contains an object of type surface.

R2019b부터는 tiledlayout 함수와 nexttile 함수를 사용하여 플롯을 타일 형식 배열로 표시할 수 있습니다. tiledlayout 함수를 호출하여 2×1 타일 형식 차트 레이아웃을 만듭니다. nexttile 함수를 호출하여 axes 객체 ax1ax2를 만듭니다. axes 객체를 colormap 함수에 전달하여 각 좌표축에 다른 컬러맵을 지정합니다. 상부 좌표축에서 spring 컬러맵을 사용하여 곡면 플롯을 만듭니다. 하부 좌표축에서 winter 컬러맵을 사용하여 곡면 플롯을 만듭니다.

tiledlayout(2,1)
ax1 = nexttile;
surf(peaks)
colormap(ax1,spring)

ax2 = nexttile; 
surf(peaks)
colormap(ax2,winter)

Figure contains 2 axes objects. Axes object 1 contains an object of type surface. Axes object 2 contains an object of type surface.

정수를 내장 컬러맵에 입력 인수로 전달하여 컬러맵에 사용되는 색의 개수를 지정합니다. 파룰라(parula) 컬러맵에 있는 5개의 색을 사용합니다.

mesh(peaks)
colormap(parula(5))

Figure contains an axes object. The axes object contains an object of type surface.

0.0과 1.0 사이의 값으로 구성된 3열 행렬을 정의하여 사용자 지정 컬러맵을 만듭니다. 각 행은 요소를 3개 가진 RGB 3색을 정의합니다. 첫 번째 열은 빨간색 농도를 지정합니다. 두 번째 열은 녹색 농도를 지정합니다. 세 번째 열은 파란색 농도를 지정합니다.

처음 두 개의 열을 0으로 설정하여 파란색 값의 컬러맵을 사용합니다.

map = [0 0 0.3
    0 0 0.4
    0 0 0.5
    0 0 0.6
    0 0 0.8
    0 0 1.0];

surf(peaks)
colormap(map)

Figure contains an axes object. The axes object contains an object of type surface.

peaks 함수의 곡면 플롯을 만들고 컬러맵을 지정합니다.

mesh(peaks)
colormap(autumn(5))

Figure contains an axes object. The axes object contains an object of type surface.

플롯에 사용된 색을 정의하는 값으로 구성된 3열 행렬을 반환합니다. 각 행은 컬러맵의 한 가지 색을 지정하는 RGB 3색 값입니다.

cmap = colormap
cmap = 5×3

    1.0000         0         0
    1.0000    0.2500         0
    1.0000    0.5000         0
    1.0000    0.7500         0
    1.0000    1.0000         0

axes 객체를 colormap 함수에 전달하여 특정 좌표축의 컬러맵 값을 반환합니다.

R2019b부터 새로 추가된 tiledlayout 함수와 nexttile 함수를 사용하여 두 개의 플롯을 타일 형식 배열로 만듭니다. tiledlayout 함수를 호출하여 2×1 타일 형식 차트 레이아웃을 만듭니다. nexttile 함수를 호출하여 axes 객체 ax1ax2를 만듭니다. 그런 다음 서로 다른 컬러맵을 사용하여 채워진 두 개의 등고선 플롯을 표시합니다.

tiledlayout(2,1)
ax1 = nexttile;
contourf(peaks)
colormap(ax1,hot(8))

ax2 = nexttile;
contourf(peaks)
colormap(ax2,pink)

Figure contains 2 axes objects. Axes object 1 contains an object of type contour. Axes object 2 contains an object of type contour.

ax1colormap 함수에 전달하여 상부 플롯에 사용된 컬러맵 값을 반환합니다. 각 행은 컬러맵의 한 가지 색을 지정하는 RGB 3색 값입니다.

cmap = colormap(ax1)
cmap = 8×3

    0.3333         0         0
    0.6667         0         0
    1.0000         0         0
    1.0000    0.3333         0
    1.0000    0.6667         0
    1.0000    1.0000         0
    1.0000    1.0000    0.5000
    1.0000    1.0000    1.0000

이미지 X와 관련 컬러맵 map을 반환하는 spine 데이터 세트를 불러옵니다. image 함수를 사용하여 X를 표시하고 컬러맵을 map으로 설정합니다.

load spine
image(X)
colormap(map)

Figure contains an axes object. The axes object contains an object of type image.

입력 인수

모두 축소

새로운 색 체계를 위한 컬러맵으로, 컬러맵 이름, RGB 3색으로 구성된 3열 행렬, 또는 'default'로 지정됩니다. 컬러맵 이름은 현재 컬러맵과 동일한 개수의 색을 포함하는 미리 정의된 컬러맵입니다. RGB 3색으로 구성된 3열 행렬은 사용자 지정 컬러맵입니다. 직접 행렬을 만들거나, 미리 정의된 colormap 함수 중 하나를 호출하여 행렬을 만들 수 있습니다. 예를 들어, colormap(parula(10)) 함수는 현재 Figure의 컬러맵을 parula 컬러맵에서 선택한 10개 색으로 설정합니다.

'default' 값은 컬러맵을 대상 객체의 디폴트 컬러맵으로 설정합니다.

컬러맵 이름

다음 표에는 미리 정의된 컬러맵이 나와 있습니다.

컬러맵 이름색조

parula

Colorbar showing the colors of the parula colormap. The colormap starts at dark blue and transitions to lighter blue, green, orange and yellow. The transitions between colors are more perceptually uniform than in most other colormaps.

turbo

Colorbar showing the colors of the turbo colormap. The colormap starts at dark blue and transitions to lighter blue, bright green, orange, yellow, and dark red. This colormap is similar to jet, but the transitions between colors are more perceptually uniform than in jet.

hsv

Colorbar showing the colors of the hsv colormap. The colormap starts at red and transitions to yellow, bright green, cyan, dark blue, magenta, and bright orange.

hot

Colorbar showing the colors of the hot colormap. The colormap starts at dark red and transitions to bright red, orange, yellow, and white.

cool

Colorbar showing the colors of the cool colormap. The colormap starts at cyan and transitions to light blue, light purple, and magenta.

spring

Colorbar showing the colors of the spring colormap. The colormap starts at magenta and transitions to pink, light orange, and yellow.

summer

Colorbar showing the colors of the summer colormap. The colormap starts at medium green and transitions to yellow.

autumn

Colorbar showing the colors of the autumn colormap. The colormap starts at bright orange and transitions to yellow.

winter

Colorbar showing the colors of the winter colormap. The colormap starts at dark blue and transitions to bright green.

gray

Colorbar showing the gray colormap. The colormap starts at black and transitions to white.

bone

Colorbar showing the bone colormap. This colormap has colors that are approximately gray with a slight blue color tint. The colormap starts at dark gray and transitions to white.

copper

Colorbar showing the copper colormap. This colormap starts at black and transitions to a medium orange, similar to the color of copper.

pink

Colorbar showing the pink colormap. This colormap starts at dark red and transitions to dark pink, tan, and white.

sky (R2023a 이후)

Colorbar showing the sky colormap. This colormap starts at a very light shade of blue and transitions to a darker shade of blue.

abyss (R2023b 이후)

Colorbar showing the abyss colormap. This colormap starts at a very dark shade of blue and transitions to a lighter shade of blue.

jet

Colorbar showing the colors of the jet colormap. The colormap starts at dark blue and transitions to light blue, bright green, orange, yellow, and dark red.

lines

Colorbar showing the colors of the lines colormap. The colormap contains a repeating pattern of colors: dark blue, dark orange, dark yellow, dark purple, medium green, light blue, and dark red.

colorcube

Colorbar showing the colors of the colorcube colormap. The colormap is a course sampling of the RGB colorspace.

prism

Colorbar showing the colors of the prism colormap. The colormap contains a repeating pattern of colors: red, orange, yellow, green, blue, and purple.

flag

Colorbar showing the colors of the flag colormap. The colormap contains a repeating pattern of colors: red, white, blue, and black.

white

Colorbar showing the white colormap, which is entirely white.

3열 행렬

사용자 지정 컬러맵을 만들려면 map을 RGB 3색으로 구성된 3열 행렬로 지정하십시오. 여기서 각 행은 하나의 색을 정의합니다. RGB 3색은 요소를 3개 가진 행 벡터로, 각 요소는 색을 구성하는 빨간색, 녹색, 파란색의 농도를 지정합니다. 농도는 범위 [0, 1]의 double형 또는 single형 값이거나 범위 [0, 255]의 uint8형 값일 수 있습니다. 예를 들어, 다음 행렬은 5개 색을 포함하는 컬러맵을 정의합니다.

map = [0.2 0.1 0.5
    0.1 0.5 0.8
    0.2 0.7 0.6
    0.8 0.7 0.3
    0.9 1 0];

다음 표에는 흔히 사용되는 색의 RGB 3색 값이 나와 있습니다.

double형 또는 single형 RGB 3색uint8형 RGB 3색
노란색[1 1 0][255 255 0]
자홍색[1 0 1][255 0 255]
녹청색[0 1 1][0 255 255]
빨간색[1 0 0][255 0 0]
녹색[0 1 0][0 255 0]
파란색[0 0 1][0 0 255]
흰색[1 1 1][255 255 255]
검은색[0 0 0][0 0 0]

데이터형: char | double | single | uint8

대상으로, 다음 값 중 하나로 지정됩니다.

  • Figure 객체. Figure 컬러맵은 Figure 내에 있는 모든 좌표축의 플롯에 영향을 미칩니다.

  • Axes 객체, PolarAxes 객체 또는 GeographicAxes 객체. Figure 내에 있는 좌표축별로 고유한 컬러맵을 정의할 수 있습니다.

  • Colormap 속성을 가진 독립형 시각화. 예를 들어, HeatmapChart 객체의 컬러맵을 변경하거나 쿼리할 수 있습니다.

출력 인수

모두 축소

컬러맵 값으로, RGB 3색으로 구성된 3열 행렬로 반환됩니다. 행렬의 각 행은 컬러맵의 한 가지 색을 지정하는 하나의 RGB 3색을 정의합니다. 값의 범위는 [0, 1]입니다.

세부 정보

모두 축소

컬러맵

컬러맵은 surface, image, patch 객체와 같은 그래픽스 객체에 대한 색을 정의하는 값으로 구성된 행렬입니다. MATLAB®은 컬러맵의 색에 데이터 값을 매핑하여 객체를 그립니다.

컬러맵의 길이에는 제한이 없으나 너비는 3개 열로 제한됩니다. 행렬의 각 행은 RGB 3색을 사용하여 하나의 색을 정의합니다. RGB 3색은 요소를 3개 가진 행 벡터로, 각 요소는 색을 구성하는 빨간색, 녹색, 파란색의 농도를 지정합니다. 일반적으로 농도는 범위 [0, 1]의 double형 또는 single형 값입니다. 값이 0이면 색 없음을, 값이 1이면 완전한 농도를 의미합니다. 예를 들어, 다음 명령은 검은색, 빨간색, 녹색, 파란색, 흰색의 5가지 색으로 구성된 컬러맵을 만듭니다.

mymap = [0 0 0
    1 0 0
    0 1 0
    0 0 1
    1 1 1];

시각화의 색 체계를 변경하려면 colormap 함수를 호출하여 포함하는 좌표축이나 Figure의 컬러맵을 변경하십시오. 예를 들어, 다음 명령은 곡면 플롯을 만들고 Figure의 컬러맵을 mymap으로 설정합니다.

surf(peaks)
colormap(mymap)

Surface plotted with a custom colormap containing five colors: black, red, green, blue, and black.

  • 컬러맵 제한 및 이러한 제한과 데이터 범위의 관계를 제어하려면 clim 함수를 사용하십시오.

    R2022a 이전: clim과 동일한 구문과 인수를 가지는 caxis를 사용하십시오.

버전 내역

R2006a 이전에 개발됨

모두 확장