Colorbar in second subplot
조회 수: 1 (최근 30일)
이전 댓글 표시
Ludmila Nemsilajova
2015년 3월 21일
편집: Ludmila Nemsilajova
2015년 3월 23일
Hi, I have a question about colorbar. When I call 2 and more times my code colorbar seems like

and I don`t have idea why..
My code is there, but when i call it in console its look ok but You can see that second colorbar has bold numbers...its same as my picture, when I call it in gui with different matrix after clicks on the button it looks like in my picture :/
figure;
M = rand([10,16,4],'single');
mmax1 = max(max(M(:,:,1)));
mmin1 = min(min(M(:,:,1)));
mmax2 = max(max(M(:,:,2)));
mmin2 = min(min(M(:,:,2)));
bottom = min(mmin1,mmin2);
top = max(mmax1,mmax2);
vektor1 = [0.17, 0.45, 0.3, 0.2];
vektor2 = [0.65, 0.45, 0.3, 0.2];
vektor3 = [0.17, 0.1, 0.3, 0.2];
scale=[200 600];
scale2 =[200 600];
image = M(:,:,1);
im = imresize(image,scale);
s = subplot(3,2,3);%,'Position',vektor1),
imshow(im)
axis off;
caxis([bottom top]);
set(s,'Position',vektor1);
%c = colorbar;
colormap(jet(round(256)));
freezeColors;
c = cbfreeze(colorbar);
x1=get(gca,'position');
x=get(c,'Position');
x(3)=0.007;
set(c,'Position',x)
set(gca,'position',x1)
image = M(:,:,2);
im = imresize(image,scale);
ss = subplot(3,2,2);
set(ss,'Position',vektor2);
imshow(im);
axis off;
caxis([bottom top]);
colormap(jet(round(256)));
freezeColors;
c = cbfreeze(colorbar);
x1=get(gca,'position');
x=get(c,'Position');
x(3)=0.007;
set(c,'Position',x)
set(gca,'position',x1)
M = rand([10,16,5],'single');
mmax1 = max(max(M(:,:,1)));
mmin1 = min(min(M(:,:,1)));
mmax2 = max(max(M(:,:,2)));
mmin2 = min(min(M(:,:,2)));
bottom = min(mmin1,mmin2);
top = max(mmax1,mmax2);
image = M(:,:,1);
im = imresize(image,scale);
s = subplot(3,2,3);%,'Position',vektor1),
imshow(im)
axis off;
caxis([bottom top]);
set(s,'Position',vektor1);
%c = colorbar;
colormap(jet(round(256)));
freezeColors;
c = cbfreeze(colorbar);
x1=get(gca,'position');
x=get(c,'Position');
x(3)=0.007;
set(c,'Position',x)
set(gca,'position',x1)
image = M(:,:,2);
im = imresize(image,scale);
ss = subplot(3,2,2);
set(ss,'Position',vektor2);
imshow(im);
axis off;
caxis([bottom top]);
colormap(jet(round(256)));
freezeColors;
c = cbfreeze(colorbar);
x1=get(gca,'position');
x=get(c,'Position');
x(3)=0.007;
set(c,'Position',x)
set(gca,'position',x1)
M = rand([10,16,2],'single');
mmax1 = max(max(M(:,:,1)));
mmin1 = min(min(M(:,:,1)));
mmax2 = max(max(M(:,:,2)));
mmin2 = min(min(M(:,:,2)));
bottom = min(mmin1,mmin2);
top = max(mmax1,mmax2);
vektor1 = [0.17, 0.45, 0.3, 0.2];
vektor2 = [0.65, 0.45, 0.3, 0.2];
vektor3 = [0.17, 0.1, 0.3, 0.2];
scale=[200 600];
scale2 =[200 600];
image = M(:,:,1);
im = imresize(image,scale);
s = subplot(3,2,3);%,'Position',vektor1),
imshow(im)
axis off;
caxis([bottom top]);
set(s,'Position',vektor1);
%c = colorbar;
colormap(jet(round(256)));
freezeColors;
c = cbfreeze(colorbar);
x1=get(gca,'position');
x=get(c,'Position');
x(3)=0.007;
set(c,'Position',x)
set(gca,'position',x1)
image = M(:,:,2);
im = imresize(image,scale);
ss = subplot(3,2,2);
set(ss,'Position',vektor2);
imshow(im);
axis off;
caxis([bottom top]);
colormap(jet(round(256)));
freezeColors;
c = cbfreeze(colorbar);
x1=get(gca,'position');
x=get(c,'Position');
x(3)=0.007;
set(c,'Position',x)
set(gca,'position',x1)
EDIT: It seems like that problem is with subplot(3,2,2) not only colorbar.
Sorry for my bad english.
댓글 수: 4
채택된 답변
추가 답변 (1개)
Image Analyst
2015년 3월 21일
I don't know but it may have something to do with freezecolors() - a function that is no longer needed after R2014b since each axes can now have its own colormap. I'd suggest either upgrading to R2015a, or get the handle to the colorbar and delete it
h = colorbar()
% Later...before second colorbar
delete(h);
h = colorbar()
Or try turning it off and on again before you set it.
colorbar('off')
colorbar('on')
h = colorbar()
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!