gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 18:54:12 26 4
gpt4 key购买 nike

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

下面的可重现代码:

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/

26 4 0