Colorbar in second subplot
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ludmila Nemsilajova
le 21 Mar 2015
Modifié(e) : Ludmila Nemsilajova
le 23 Mar 2015
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 commentaires
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 21 Mar 2015
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()
Voir également
Catégories
En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!