フィルターのクリア

Creating a colorbar in Matlab

22 ビュー (過去 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()
  1 件のコメント
Lavenia
Lavenia 2024 年 2 月 14 日
Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeColormaps についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by