common colorbar

6 views (last 30 days)
blaz
blaz on 20 Apr 2011
Dear all,
I made a function f_colorbar.m enabling me to customize a colorbar. However, all of a sudden (& months ago it work without the error and in between I did not change anything at least to my knowledge that could cause this) I get this warning-error:
>> Error in ==> legendcolorbarlayout>layoutColorbar at 829 [width,height]=preferredColorbarSize(origc);
??? Output argument "newpos" (and maybe others) not assigned during call to "C:\Program Files\MATLAB\R2010b\toolbox\matlab\scribe\legendcolorbarlayout.m>layoutColorbar".
Error in ==> legendcolorbarlayout>doInOutLayout at 498 [newpos,corners] = layoutColorbar(location,corners,origc);
Error in ==> legendcolorbarlayout>doLayout at 441 doInOutLayout(par,fig,outlist,corner1,corner2,false);
Error in ==> legendcolorbarlayout>doParentResize at 338 doLayout(ch);
Warning: Error occurred while evaluating listener callback. > In legendcolorbarlayout>reclaimSpace at 1002 In legendcolorbarlayout at 88 In scribe.colorbar.init>changedLocation at 92 In scribe.colorbar.init>changedPos at 116 In f_colorbar at 125 >>
The 125 line says set(hcb,'position',newpos). By the way, on my other computer, having the same matlab (2010b) and the same OS (Win 7 x64) I do not encounter this issue.
Any ideas, ... anything ?
Cheers
Blaz

Accepted Answer

Matt Tearle
Matt Tearle on 20 Apr 2011
Hard to say without seeing the code, but it looks like there's some condition that makes it possible for layoutColorbar to complete without newpos ever being defined -- that's the initial warning, which then leads to the error on line 125 of f_colorbar. Presumably it's a subtle bug in the logic which hasn't manifested until now.
With the Editor, you can highlight a variable and see where it shows up in that file. Maybe you can use that to trace the creation of newpos and see if there's anything that could prevent it. You could also simply try putting a breakpoint in layoutColorbar and stepping through (when running an example you know is failing).
  1 Comment
blaz
blaz on 20 Apr 2011
Dear Matt,
thank you for your answer. I have appended a piece of a code where I move the colorbar inside the picture or figure. The interesting thing is that it worked before and just to be on the same page... the program doesn't crash it just puts this warning and the final figure looks like it should. It's just annoying that I don't know why it does that. I will look into the layoutColorbar code more closely.
case 'right'
set(hcolbar,'location','eastoutside');
% make the figure wider
figpos(3) = figpos(3)+w+g;
set(hf,'position',figpos);
% colorbar position
bpos(1) = figpos(3)-ehr-w;
bpos(2) = evb+((figpos(4)-evb-evt-h)/2);
bpos(3) = w;
bpos(4) = h;
set(hcolbar,'position',bpos);
Best
Blaz

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!