필터 지우기
필터 지우기

Creating a colorbar in Matlab

조회 수: 21 (최근 30일)
Lavenia
Lavenia 2024년 2월 14일
댓글: Lavenia 2024년 2월 14일
Im new to understanding Matlab and i have a two part question.
1. Is this colorbar automatic colors? As in Matlab picks its default colours? Because i do not choose colours anyhere, and just type these two commands in and i get a blue/yellow/green colour on the figure. What does cb stand for?
colorbar;
cb = colorbar;
2. Is there a way to create a manual colour bar using these colours? #0192bf, #41abce, #ffff00, #ffff41, #ffff7f. Im making a contour plot using contourf
  댓글 수: 1
Dyuman Joshi
Dyuman Joshi 2024년 2월 14일
"Is this colorbar automatic colors?"
The colorbar just displays the bar which shows the color scale of the figure.
"As in Matlab picks its default colours?"
Yes.
"What does cb stand for?"
cb is the handle to the colorbar object.
"Is there a way to create a manual colour bar using these colours? #0192bf, #41abce, #ffff00, #ffff41, #ffff7f. Im making a contour plot using contourf "
See the section on making a custom colormap on this page - colormap.
There are loads of other questions on this forum with examples of making custom colormaps for a figure. Go through them.

댓글을 달려면 로그인하십시오.

채택된 답변

Stephen23
Stephen23 2024년 2월 14일
"Is this colorbar automatic colors? As in Matlab picks its default colours?"
Yes. The default colormap is described here:
"What does cb stand for?"
I guess that CB stands for "ColorBar". But the name of that variable is much less important than what it is: a COLORBAR object:
"Is there a way to create a manual colour bar using these colours? #0192bf, #41abce, #ffff00, #ffff41, #ffff7f."
S = ['#0192bf'; '#41abce'; '#ffff00'; '#ffff41'; '#ffff7f'];
M = sscanf(S.','#%2x%2x%2x',[3,Inf]).' ./ 255;
Z = peaks;
contourf(Z)
colormap(M)
colorbar()

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by