2017-08-13 71 views
0

我想在顏色欄上創建第二個標尺,但是標記的值已關閉,例如0.2應爲14.33,0.4應爲13.57等等。MATLAB - 色標的第二個標尺關閉

這是代碼的相關位:在我看來

hFig = figure('Name','False Color Luminance Map', 'ToolBar','none', 'MenuBar','none'); 
% Create/initialize default colormap of jet. 
cmap = parula(16); % or 256, 64, 32 or whatever. 
% Now make lowest values show up as black. 
cmap(1,:) = 0; 
% Now make highest values show up as white. 
cmap(end,:) = 1; 


imshow(J,'Colormap',cmap) % show Image in false color 

colorbar % add colorbar 


h = colorbar; % define colorbar as variable 
caxis auto 
y_Scl = (1/C); 
yticks = get(h,'YTick'); 
set(h,'YTickLabel',sprintfc('%g', [yticks.*y_Scl])) 




ylabel(h, 'cd/m^2')% add unit label 


BarPos = get(h,'position'); 
haxes = axes('position',BarPos,'color','none','ylim',[0 150]); 
set(haxes,'YTickLabel', sprintfc('%g', log10(yticks.*y_Scl/108000)/-0.4)); 

錯誤有在最後兩行是什麼地方。

enter image description here 編輯: 當我改變 haxes =軸( '位置',BarPos, '顏色', '無', 'ylim',[0 150]); haxes = axes('position',BarPos,'color','none','ylim',[0 150]); 我得到這個 enter image description here 所有正確的值在那裏,但沒有正確對齊!

回答

1
BarPos = get(h,'position'); 
haxes = axes('position',BarPos,'color','none','ylim',[0 115]); 
set(haxes,'YTickLabel', sprintfc('%.3g', log10(yticks.*y_Scl/108000)/-0.4)); 
yt1 = get(h, 'YTick'); 
yL1 = get(h, 'YLim'); 
t1ratio = (yt1 - yL1(1))./(yL1(2)-yL1(1)); 
yL2 = get(haxes, 'YLim'); 
yt2 = t1ratio .* (yL2(2)-yL2(1)) + yL2(1); 
set(haxes, 'YTick', yt2) 

這個工程nicly我的問題