1. colormap函数
用法:colormap(map);将图形设置为map颜色
colormap(‘default’);设置当前图形的颜色为默认颜色
cmap=colormap;获取当前图形的颜色矩阵
举例:
[x,y,z]=sphere(40);%画球体
mesh(x,y,z);
colormap(jet);

colormap中的颜色可以是自己定义的RGB颜色向量如[0,0,1],也可以使用matlab提供的颜色函数(jet、hsv、hot、cool、spring、summer、autumn、winter、gray、bone、copper、pink、lines)。
2. shading函数
用法:
shading faceted;
shading flat;
shading interp;
举例:
subplot(3,1,1);
sphere(16);
axis square;
shading faceted;
title(‘1’);
subplot(3,1,2);
sphere(16);
axis square;
shading flat;
title(‘2’);
subplot(3,1,3);
sphere(16);
axis square;
shading interp;
title(‘3’);

本文详细介绍Matlab中用于控制图形颜色的多种函数,包括colormap、shading、caxis、brighten、colorbar和colordef。通过这些函数,用户可以自定义图形的颜色映射、阴影效果、颜色轴范围、亮度调整及背景颜色,实现对图形颜色的精确控制。


被折叠的 条评论
为什么被折叠?



