Colorbar in second subplot

1 次查看(过去 30 天)
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 个评论
Image Analyst
Image Analyst 2015-3-21
What version of MATLAB do you have? Hopefully it's R2014b or later.
Ludmila Nemsilajova
I tried it on R2014b and R2012b but it looks same on both.

请先登录,再进行评论。

采纳的回答

Ludmila Nemsilajova
编辑:Ludmila Nemsilajova 2015-3-23
I solved it, I replaced all
s = subplot(3,2,3);%,'Position',vektor1),
set(s,'Position',vektor1);
by
subplot('Position',vektor1),
and it works!

更多回答(1 个)

Image Analyst
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()
  1 个评论
Ludmila Nemsilajova
Thanks for your answer. It looks same when I comment freezeColors; but I have same colormap on subplots...delete and colormap('off') doesn't work :/

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by