Colorbar in second subplot

1 visualizzazione (ultimi 30 giorni)
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 Commenti
Image Analyst
Image Analyst il 21 Mar 2015
What version of MATLAB do you have? Hopefully it's R2014b or later.
Ludmila Nemsilajova
Ludmila Nemsilajova il 22 Mar 2015
I tried it on R2014b and R2012b but it looks same on both.

Accedi per commentare.

Risposta accettata

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

Più risposte (1)

Image Analyst
Image Analyst il 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()
  1 Commento
Ludmila Nemsilajova
Ludmila Nemsilajova il 21 Mar 2015
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 :/

Accedi per commentare.

Categorie

Scopri di più su Image Processing Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by