【问题标题】:MATLAB - Second scale of colorbar is offMATLAB - 颜色条的第二个比例关闭
【发布时间】:2017-08-13 13:51:05
【问题描述】:

我想在颜色条上制作第二个刻度,但刻度的值已关闭,例如 0.2 应该是 14.33 , 0.4 应该是 13.57 等等。

这是相关的代码:

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));

在我看来,错误必须在最后两行的某个地方。

编辑: 当我改变 haxes = 轴('位置',BarPos,'颜色','无','ylim',[0 150]); 到 haxes = 轴('位置',BarPos,'颜色','无','ylim',[0 150]); 我明白了 所有正确的值都在那里,但没有正确对齐!

【问题讨论】:

    标签: image matlab axis-labels colorbar


    【解决方案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)
    

    这非常适合我的问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-21
      • 2020-10-19
      • 1970-01-01
      • 2015-06-03
      • 2012-06-13
      • 2021-08-06
      相关资源
      最近更新 更多