如何添加标记到Matlab颜色栏? [英] How to add marker to matlab colorbar?
本文介绍了如何添加标记到Matlab颜色栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在Matlab颜色栏中通过特定值添加tarker/特殊刻度线.例如,假设我的色标范围从-20到60,而我的临界值为37.53,如何通过该色标的值添加标记?
I want to add a tarker/special tick mark by specific values in my matlab colorbars. For example, lets say I have a colorbar scale from -20 to 60 and my critical value is 37.53, how can I add a marker by that value of the colorbar?
推荐答案
colorbar
实际上是一个axes
对象,因此您可以像添加任何坐标轴一样添加刻度线:
The colorbar
is really an axes
object, so you can add tickmarks like you would any 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);
编辑:在评论中,您要求一种使自定义刻度线在其余标记中脱颖而出的方法.您可以使用以下方法制作一个粗体的勾号:
Edit: In the comments, you have asked for a way to make the custom tick mark stand out amongst the rest. You can make a single bold tick mark using the following method:
% 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');
这篇关于如何添加标记到Matlab颜色栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文