matlab - 使颜色条的框架变白,同时保持标签为黑色

标签 matlab border customization matlab-figure colorbar

如何使颜色条框周围的矩形线变为白色,但使刻度标签保持黑色?

下面的可重现代码:

colormap(flipud(autumn(6))); % Create Colormap
         cb = colorbar; % Create Colorbar         
         cb.Ticks = [.1667 .3334 .5001 .6668 .8335]; % Create ticks
         cb.TickLabels = ({'0%','5%','10%','15%','20%'});    
         cb.TickLength = 0;
         cb.Color = 'w'; % Everything becomes white, I only want the rectangular color of the box to be white

最佳答案

您可以通过在颜色条上叠加一个白色注释框来获得想要的视觉效果,例如

    colormap(flipud(autumn(6))); % Create Colormap
             cb = colorbar; % Create Colorbar         
             cb.Ticks = [.1667 .3334 .5001 .6668 .8335]; % Create ticks
             cb.TickLabels = ({'0%','5%','10%','15%','20%'});    
             cb.TickLength = 0;
             % cb.Color = 'w'; % Everything becomes white, I only want the rectangular color of the box to be white

    annotation('rectangle',cb.Position,'Color','w','FaceColor','none','LineWidth',2)

关于matlab - 使颜色条的框架变白,同时保持标签为黑色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66408322/

相关文章:

r - 多瓦尔 : from Matlab to R

matlab - 如何在Matlab代码的一个音频 channel 上同时输出由两个具有不同时间段的信号组成的复合信号?

android - 如何用ImageView制作边框?

R中的绘图周围的圆形边框

html - 为什么我的边框图像在 IE11 中不起作用?

json - Openresty自定义json访问日志

matlab - 如何将非常大的 MATLAB 稀疏矩阵保存到文本文件中?

multithreading - MATLAB 上的进程间通信

.NET 资源层次结构与文化无关

android - 以 29(Q) 作为目标 API 的 28(P) 的 EditText 句柄颜色