필터 지우기
필터 지우기

Different colors within each plot of subplot

조회 수: 13 (최근 30일)
HT
HT 2019년 10월 2일
편집: HT 2019년 10월 4일
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
HT
HT 2019년 10월 2일
I think there are 7 default colors (8 including white) after which it starts repeating the colors.
Walter Roberson
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
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
  댓글 수: 1
HT
HT 2019년 10월 2일
I tried this but as I mentioned in the question, this generates subplots of different colors but same color in each sublpot (i.e.all 8 line plots within the subplot are same color). I want each lines within each plot to be different. Each subplot has 8 plots in it ---- plot(X, Y(i:8:end,:)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by