Matlab相同标记线的颜色
Matlab same markers' color of line
我定义了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);
但不起作用。如果我用 'r'
替换 color_red
,整个正方形变成红色,而我只需要给边缘着色;我需要 color_red
的确切红色,因为我会为其他图表做这件事。
如果我使用 Matlab 提供的标准颜色,它就可以工作。但是我不能使用那种颜色。
您正在将 字符串 '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
which is the center portion of the marker. You want to set the MarkerFaceColor
to none
and instead set the 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
我定义了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);
但不起作用。如果我用 'r'
替换 color_red
,整个正方形变成红色,而我只需要给边缘着色;我需要 color_red
的确切红色,因为我会为其他图表做这件事。
如果我使用 Matlab 提供的标准颜色,它就可以工作。但是我不能使用那种颜色。
您正在将 字符串 '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
which is the center portion of the marker. You want to set the MarkerFaceColor
to none
and instead set the 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