Different colors within each plot of subplot
27 次查看(过去 30 天)
显示 更早的评论
In the sample code below, Y has 64 rows and each subplot has 8 2-D line plots in it (total 8 subplots). I want each of these 8 lines in each subplot to be of distinct colors. I have defined colors (8x3 matrix) but it is producing each subplot of different color and not lines within each subplot.
Sample code :
figure
for i = 1:8
subplot(2,4,i); plot(X,Y(i:8:end,:));
end
4 个评论
Walter Roberson
2019-10-2
No white -- no pure colors at all
>> get(gca,'ColorOrder')
ans =
0 0.447 0.741
0.85 0.325 0.098
0.929 0.694 0.125
0.494 0.184 0.556
0.466 0.674 0.188
0.301 0.745 0.933
0.635 0.078 0.184
回答(1 个)
Walter Roberson
2019-10-2
cmap = copper(8); %or other color map
for i = 1:8
subplot(2,4,i); plot(X, Y(i:8:end,:), 'Color', cmap(i,:));
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!