MATLAB Multiple Line Colors Guide

In MATLAB, the ‘Color’ parameter can be used to set the color of the line. Here are some methods for setting the color of a line:

  1. Use predefined color names:
plot(x, y, 'Color', 'red')  % 设置线条为红色
plot(x, y, 'Color', 'blue')  % 设置线条为蓝色
  1. Use RGB values:
plot(x, y, 'Color', [1, 0, 0])  % 设置线条为红色
plot(x, y, 'Color', [0, 0, 1])  % 设置线条为蓝色
  1. Utilize hexadecimal color codes:
plot(x, y, 'Color', '#FF0000')  % 设置线条为红色
plot(x, y, 'Color', '#0000FF')  % 设置线条为蓝色
  1. Utilize color mapping:
colormap jet  % 使用'jet'颜色映射
plot(x, y)  % 绘制线条,并根据x或y值的大小自动选择颜色

Here are some methods for setting line colors. You can choose the appropriate method based on your needs to set multiple colors for the lines.

bannerAds