【问题标题】:How to add marker to matlab colorbar?如何将标记添加到matlab颜色条?
【发布时间】:2013-05-13 22:27:19
【问题描述】:

我想通过我的 matlab 颜色栏中的特定值添加一个 tarker/特殊刻度线。例如,假设我有一个从 -20 到 60 的颜色条比例,我的临界值为 37.53,我如何通过颜色条的该值添加标记?

【问题讨论】:

    标签: matlab graphing colorbar


    【解决方案1】:

    colorbar 实际上是一个 axes 对象,因此您可以像添加任何轴一样添加刻度线:

    myTick = 37.53;
    
    c = colorbar();
    ticks = get(c, 'YTick');
    % Add your tick and sort so it's monotonically increasing
    ticks = sort([ticks myTick]);
    set(c, 'YTick', ticks);
    

    编辑:在 cmets 中,您要求一种方法使自定义刻度线在其他标记中脱颖而出。您可以使用以下方法制作一个粗体标记:

    % Here is an example plot
    pcolor(rand(100));
    c = colorbar();
    myTick = 0.45; % Change this for real data
    
    % Create a copy of the colorbar with transparent background and overlay
    c2 = copyobj(c, gcf);
    alpha(get(c2, 'Children'), 0);
    set(c2, 'Color', 'none');
    set(c2, 'Position', get(c, 'Position'));
    
    % Give the copy a single tick mark and set its font style
    set(c2, 'YTick', myTick);
    set(c2, 'FontWeight', 'bold');
    

    【讨论】:

    • 谢谢 Wakjah,但您的解决方案不会使关键的刻度线从所有其他刻度线中脱颖而出。有什么方法可以让它在视觉上脱颖而出?
    猜你喜欢
    • 1970-01-01
    • 2017-12-23
    • 1970-01-01
    • 2016-10-19
    • 1970-01-01
    • 1970-01-01
    • 2019-09-09
    • 2015-08-16
    • 1970-01-01
    相关资源
    最近更新 更多