Control colorbar in a plot

6 ビュー (過去 30 日間)
antonio ferreira
antonio ferreira 2018 年 2 月 17 日
回答済み: antonio ferreira 2018 年 2 月 18 日
Dear all, I was wondering if anyone knows a way of controlling the colorbar of a plot? At the moment I have the following code: subplot(3,1,3); [cs2,h2]=contourf(xgrid,ygrid,U_40cm,10); hold on; clabel(cs2,h2); h2.LevelList = round(h2.LevelList, 2); set(gca, 'CLim', [-25 20]); xlabel('$y$ $(cm)$','interpreter','latex','Fontsize',14,'Fontname','Times'), ylabel('$z$ $(cm)$','interpreter','latex','Fontsize',14,'Fontname','Times'), %set(gca,'xtick',83:1:92,'Fontsize',16,'Fontname','Times'), %set(gca,'ytick',1:0.5:4,'Fontsize',16,'Fontname','Times'), axis([83 92 1.2 3.9]); colormap('jet')
In the colorbar, matlab is just presenting the values -20,0,20. Is there any way of forcing matlab to present instead -20,-10,0,10,20? I need this to make the appearance of this plot compatible with other plot. Thanks in advance.

回答 (2 件)

antonio ferreira
antonio ferreira 2018 年 2 月 17 日
Dear all, I was wondering if anyone knows a way of controlling the colorbar of a plot? At the moment I have the following code:
subplot(3,1,3);
[cs2,h2]=contourf(xgrid,ygrid,U_40cm,10); hold on;
clabel(cs2,h2);
h2.LevelList = round(h2.LevelList, 2);
set(gca, 'CLim', [-25 20]);
xlabel('$y$ $(cm)$','interpreter','latex','Fontsize',14,'Fontname','Times'),
ylabel('$z$ $(cm)$','interpreter','latex','Fontsize',14,'Fontname','Times'),
axis([83 92 1.2 3.9]);
colormap('jet')
title('ds = 40 cm')
In the colorbar, matlab is just presenting the values -20,0,20. Is there any way of forcing matlab to present instead -20,-10,0,10,20? I need this to make the appearance of this plot compatible with other plot. Thanks in advance.

antonio ferreira
antonio ferreira 2018 年 2 月 18 日
All, the following seems to answer my question (after invoking the colormap function):
cbh=colorbar;
cbh.TickLabels = num2cell([-20 -10 0 10 20]);

カテゴリ

Help Center および File ExchangeColor and Styling についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by