Matlab相同标记的线条颜色

时间:2016-06-17 21:10:19

标签: matlab graph colors matlab-figure

我定义了4种颜色:

color_green = [31 135 16] ./ 255;
color_red = [244 56 47] ./ 255;
color_light_blue = [23 222 230] ./ 255;
color_purple = [192 4 247] ./ 255;

因为我有很多数字,我正在使用this function 我想为标记使用相同的线条颜色。我试过这个

line_fewer_markers(x,y1,30,'s','LineStyle', 'none', 'LineWidth', 2,'MarkerFaceColor','color_red');
plot(x,y2,'Color', color_red,'LineWidth',2);

但不起作用。如果我用color_red替换'r',则整个方块变为红色,而我只需要将边缘着色;我需要color_red的确切红色,因为我会为其他图表做这件事。 如果我使用Matlab提供的标准颜色,它的工作原理。但我不能使用那种颜色。

1 个答案:

答案 0 :(得分:2)

您正在将字符串 'color_red'而不是变量 color_red传递给line_fewer_markers

line_fewer_markers(x,y1,30,'s', ...
                'LineStyle', 'none', ...
                'LineWidth', 2, ...
                'MarkerFaceColor', color_red);  %<---- Pass the VARIABLE not a string

此外,您还要设置MarkerFaceColor,它是标记的中心部分。您想将MarkerFaceColor设置为none,而是设置MarkerEdgeColor

line_fewer_markers(x,y1,30,'s', ...
                'LineStyle', 'none', ...
                'LineWidth', 2, ...
                'MarkerFaceColor', 'none', ...   %<-- Don't fill the markers
                'MarkerEdgeColor', color_red);   %<-- Set the EdgeColor
相关问题