更新时间:2023-02-20 13:59:09
您可以拥有 PLOT 自动为您选择线条颜色.如果所有6个向量的长度都相同,则可以将x和y坐标放入N×6矩阵X
和Y
中,并将它们传递给
You can have PLOT automatically choose line colors for you. If all 6 of your vectors are the same length, you can put the x and y coordinates into N-by-6 matrices X
and Y
and pass these to PLOT. A different color will be used for each column:
plot(X,Y,'-s'); %# Plots lines with square markers
您还可以使用一些内置的颜色图来生成一组颜色,然后在分别绘制每条线时使用这些颜色.例如:
You could also use some of the built-in colormaps to generate a set of colors, then use these when you plot each line separately. For example:
cmap = hsv(6); %# Creates a 6-by-3 set of colors from the HSV colormap
for i = 1:6 %# Loop 6 times
plot(X(:,i),Y(:,i),'-s','Color',cmap(i,:)); %# Plot each column with a
%# different color
end