MATLAB 帮助中心
本页翻译不是最新的。点击此处可查看最新英文版本。
线条颜色图数组
c = lines
c = lines(m)
c = lines 以一个三列数组的形式返回线条颜色图,该数组包含的行数与当前图窗 (gcf) 的颜色图相同。如果不存在图窗,则数组包含 256 行。数组中的每一行包含一种特定颜色的红、绿、蓝强度。强度在 [0,1] 范围内,颜色方案与 Axes 的默认 ColorOrder 属性匹配。因此,您可以使用此颜色图使图形颜色与 plot 函数的输出匹配。
gcf
Axes
ColorOrder
plot
c = lines(m) 返回包含 m 种颜色的颜色图。
m
示例
全部折叠
使用默认颜色创建散点图。
x = [3.5 3.3 5 6.1 4 2]; y = [14 5.7 12 6 8 9]; sz = 100*[6 100 20 3 15 20]; c = [1 2 3 4 5 6]; scatter(x,y,sz,c,'filled','MarkerEdgeColor','k','MarkerFaceAlpha',.7); xlim([1 7]); ylim([1 16]);
获取具有六个条目的线条颜色图数组。然后替换散点图中的颜色图。
c = lines(6); colormap(c);
256
颜色数,指定为非负整数。m 的默认值为当前图窗的颜色图中的颜色数。如果不存在图窗,则默认值为 256。
数据类型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64
single
double
int8
int16
int32
int64
uint8
uint16
uint32
uint64
全部展开
从 R2019b 开始,颜色图默认有 256 种颜色。
在 R2019a 和以前的版本中,默认大小为 64。如果您的代码依赖于有 64 种颜色的颜色图,请在为图窗、坐标区或图设置颜色图时指定颜色数。例如,colormap(lines(64)) 将图窗的颜色图设置为 64 色 lines 颜色图。
colormap(lines(64))
lines
您也可以更改 MATLAB® 会话内所有图窗的默认颜色图:
set(groot,'defaultFigureColormap',lines(64))
colormap
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处