Putting a label on the colorbar in imagesc plot

16 ビュー (過去 30 日間)
F.O
F.O 2017 年 12 月 10 日
コメント済み: Image Analyst 2017 年 12 月 11 日
Hello helpers, How I will put a label on the colorbar in the plot to show what it is actually representing ,there is nothing about it in the help pages. thanks for your help.
figure(9) z0=-0.6;
r0=0.3;
[xx,zz]=meshgrid(3.5:0.02:5.5,0:-0.01:-1.5);
rr0=-(zz-z0).^2;
vz1=1.55-0.48*zz-0.8*exp(rr0/r0);
contour(xx,zz,vz11,'showtext','on')
ylabel('Depth(km)') ;
xlabel('Distance in the x direction (km)')
title ('Exercise 8c1');
figure(10)
vz12 = 1.55-0.48*zz;
meshc(xx,zz,vz12)
ylabel(' Depth (km)'); xlabel('Distance in the x direction (km)');
zlabel('P_velocity(km/s)')
title ('Exercise 8c'); %d
figure(11) imagesc(x,z,vz11) colorbar ylabel(' Depth (km)'); xlabel('Distance in the x direction (km)'); zlabel('P_velocity(km/s)')
title('EX 8d1')
figure(12)
imagesc(x,z,vz12)
colorbar
ylabel(' Depth (km)');
xlabel('Distance in the x direction (km)');
zlabel('P_velocity(km/s)')
title('EX 8d2')

採用された回答

Image Analyst
Image Analyst 2017 年 12 月 10 日
I don't know why you say that. The example is right there in the help for colorbar. Did you overlook it? Here it is again:
contourf(peaks)
colorbar('Ticks',[-5,-2,1,4,7],...
'TickLabels',{'Cold','Cool','Neutral','Warm','Hot'})
Of course you can change those labels to say whatever you want.
  4 件のコメント
F.O
F.O 2017 年 12 月 11 日
編集済み: Image Analyst 2017 年 12 月 11 日
It worked now after I used
c=colorbar
c.Label.String='P_velocity(km/s)'
but it doesn't seem to work if I just put the label like this:
colorbar('P_velocity(km/s)')
Image Analyst
Image Analyst 2017 年 12 月 11 日
That shouldn't be necessary. Passing a cell array of several strings into colorbar() should work. That's why you should call tech support.
Other than that, your alternative way puts up only one label, not several of them. If you want several labels going up beside the colorbar, then you have to pass several string labels via a cell array.

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by