Matlab 默认颜色顺序和类型
Matlab Default Color Orders and Types
我正在寻找一种方法(最好是 GUI)来全局更改默认线条颜色、它们的顺序和类型。
我想指定第一行是这个颜色,这个类型,这个宽度;第二行是那种颜色、那种类型和那种宽度;等等。
也许行名是行号(第一行、第二行等),第二列指定颜色,第三列指定类型,第四列指定宽度。像这样。
解决这个问题的好方法是什么?
这不完全是您要查找的自定义设置,但您可以设置默认的 colors 和行 types (--, -.,等等)分别使用DefaultAxesColorOrder
和DefaultAxesLineStyleOrder
:
myColorOrder = [
0 0.4470 0.7410 % rgb triplet
0.8500 0.3250 0.0980
0.9290 0.6940 0.1250
0.4940 0.1840 0.5560
0.4660 0.6740 0.1880
0.3010 0.7450 0.9330
0.6350 0.0780 0.1840]
set(groot,'DefaultAxesColorOrder',myColorOrder,...
'DefaultAxesLineStyleOrder','-|--|:|-.')
Z = peaks;
x = 1:length(Z);
y = Z(4:7,:);
plot(x,y)
3列矩阵myColorOrder
中的行包含描述颜色的RGB三元组,该矩阵的行序对应设置DefaultAxesColorOrder
属性时的行色序。默认线条样式(设置为 DefaultAxesLineStyleOrder
属性)是包含由 |
.
分隔的线条样式的单个字符串
请注意,当设置多种颜色和线条样式时,绘图将循环如下:
- 对于第一行样式:循环显示所有颜色
- 更改为下一种线条样式:循环显示所有颜色
- ...
详情见
如果您真的想自定义,您可能需要编写绘图包装器来自定义 "manual way" 中的绘图线规格,但是包装器巧妙地执行了此操作。参见例如the code for Arrow3
by Tom Davis:
The current LineStyleOrder property will be used if LineStyle is
specified with '*'. MATLAB cycles through the line styles defined by
the LineStyleOrder property only after using all colors defined by the
ColorOrder property. If however, the global variable LineWidthOrder
is defined, and LineWidth is specified with '/', then each line will
be drawn with sequential color, linestyle, and linewidth.
也许您可以利用 Tom Davis 的方法并将其应用于 Matlab 线图。
我正在寻找一种方法(最好是 GUI)来全局更改默认线条颜色、它们的顺序和类型。
我想指定第一行是这个颜色,这个类型,这个宽度;第二行是那种颜色、那种类型和那种宽度;等等。
也许行名是行号(第一行、第二行等),第二列指定颜色,第三列指定类型,第四列指定宽度。像这样。
解决这个问题的好方法是什么?
这不完全是您要查找的自定义设置,但您可以设置默认的 colors 和行 types (--, -.,等等)分别使用DefaultAxesColorOrder
和DefaultAxesLineStyleOrder
:
myColorOrder = [
0 0.4470 0.7410 % rgb triplet
0.8500 0.3250 0.0980
0.9290 0.6940 0.1250
0.4940 0.1840 0.5560
0.4660 0.6740 0.1880
0.3010 0.7450 0.9330
0.6350 0.0780 0.1840]
set(groot,'DefaultAxesColorOrder',myColorOrder,...
'DefaultAxesLineStyleOrder','-|--|:|-.')
Z = peaks;
x = 1:length(Z);
y = Z(4:7,:);
plot(x,y)
3列矩阵myColorOrder
中的行包含描述颜色的RGB三元组,该矩阵的行序对应设置DefaultAxesColorOrder
属性时的行色序。默认线条样式(设置为 DefaultAxesLineStyleOrder
属性)是包含由 |
.
请注意,当设置多种颜色和线条样式时,绘图将循环如下:
- 对于第一行样式:循环显示所有颜色
- 更改为下一种线条样式:循环显示所有颜色
- ...
详情见
如果您真的想自定义,您可能需要编写绘图包装器来自定义 "manual way" 中的绘图线规格,但是包装器巧妙地执行了此操作。参见例如the code for Arrow3
by Tom Davis:
The current LineStyleOrder property will be used if LineStyle is specified with '*'. MATLAB cycles through the line styles defined by the LineStyleOrder property only after using all colors defined by the ColorOrder property. If however, the global variable LineWidthOrder is defined, and LineWidth is specified with '/', then each line will be drawn with sequential color, linestyle, and linewidth.
也许您可以利用 Tom Davis 的方法并将其应用于 Matlab 线图。