Subplot with colormap color

조회 수: 4 (최근 30일)
Miraboreasu
Miraboreasu 2022년 9월 14일
댓글: Walter Roberson 2022년 9월 15일
Hello,
I have a cell of 35 arrays. I want to plot them on 5 subplot, namely
```
subplot(1,5,1)-subplot(1,5,5)
```
each subplot has 7 of the arrays in the following order (with a span of 35/5=7)
```
subplot(1,5,1)
plot(M{1})
hold on
plot(M{8})
...
subplot(1,5,2)
plot(M{2})
hold on
plot(M{9})
...
subplot(1,5,3)
plot(M{3})
hold on
plot(M{10})
etc
```
Also, in each subplot I would like to have a colormap for hsv(5), for example the first color(red) for hsv(5) is for all the plot in subplot(1,5,1).
Thank you

채택된 답변

Walter Roberson
Walter Roberson 2022년 9월 14일
편집: Walter Roberson 2022년 9월 14일
cmap = hsv(5);
for K = 1 : 5
thiscolor = cmap(K,:);
subplot(1,5,K);
plot(M{K}, 'color', thiscolor);
if K <= 3
hold on
plot(M{K+7}, 'color', thiscolor);
hold off
end
end
  댓글 수: 2
Miraboreasu
Miraboreasu 2022년 9월 15일
편집: Miraboreasu 2022년 9월 15일
Sorry, it is not waht I want. Let me rephase
figure
subplot(1,5,1)%All 5 arrays with hsv(1)
plot(M{1})
hold on
plot(M{6})
hold on
plot(M{11})
hold on
plot(M{16})
hold on
plot(M{21})
hold on
plot(M{26})
hold on
plot(M{31})
subplot(1,5,2)%All 5 arrays with hsv(2)
plot(M{2})
hold on
plot(M{7})
hold on
plot(M{12})
hold on
plot(M{17})
hold on
plot(M{22})
hold on
plot(M{27})
hold on
plot(M{32})
subplot(1,5,3)%All 5 arrays with hsv(3)
plot(M{3})
hold on
plot(M{8})
hold on
plot(M{13})
hold on
plot(M{18})
hold on
plot(M{23})
hold on
plot(M{28})
hold on
plot(M{33})
subplot(1,5,4)%All 5 arrays with hsv(4)
plot(M{4})
hold on
plot(M{9})
hold on
plot(M{14})
hold on
plot(M{19})
hold on
plot(M{24})
hold on
plot(M{29})
hold on
plot(M{34})
subplot(1,5,5)%All 5 arrays with hsv(5)
plot(M{5})
hold on
plot(M{10})
hold on
plot(M{15})
hold on
plot(M{20})
hold on
plot(M{25})
hold on
plot(M{30})
hold on
plot(M{35})
Walter Roberson
Walter Roberson 2022년 9월 15일
cmap = hsv(5);
for K = 1 : 5
thiscolor = cmap(K,:);
subplot(1,5,K);
for J = K:5:25
plot(M{J}, 'color', thiscolor);
hold on
end
hold off
xlim auto; ylim auto
end

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

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by