Why is colormap only applied to the last subplot?

조회 수: 6 (최근 30일)
Reza Yahyaei
Reza Yahyaei 2020년 7월 31일
편집: Reza Yahyaei 2020년 7월 31일
Hello. I made a custom (circular) colormap for phase angles. However, in the loop, only the last subplot takes the change. What is the issue in this code? Thanks!
figure
for i = 1:5
subplot(2, 5, i);
topoplot(double(squeeze(pophmat(timeidx, i, :, 1))), EEG.chanlocs, ...
'style', 'map', 'electrodes', 'off');
title(['Pwr: ' num2str(frequencies(i)) 'Hz, 180ms']);
subplot(2, 5, i+5);
topoplot(double(squeeze(pophmat(timeidx, i, :, 2))), EEG.chanlocs, ...
'style', 'map', 'electrodes', 'off');
title(['Phs: ' num2str(frequencies(i)) 'Hz, 180ms']);
colormap(gca, circular_jet); % Applying the custom colormap to the current subplot
end
  댓글 수: 2
Serhii Tetora
Serhii Tetora 2020년 7월 31일
becase current axes, that you get with gca is the last subplot
Reza Yahyaei
Reza Yahyaei 2020년 7월 31일
편집: Reza Yahyaei 2020년 7월 31일
But I tried this also with a handle h = subplot(... and the result was the same. Btw, by the last subplot I mean the last one in the whole set (10th subplot) not the second subplot in each loop.

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

채택된 답변

Reza Yahyaei
Reza Yahyaei 2020년 7월 31일
편집: Reza Yahyaei 2020년 7월 31일
I debugged my own code and realized that the issue is with the topoplot function. After applying the colormap, when it goes to plot the next one with topoplot, it reverses all the previous changes in colormaps because apparently topoplot implicitly applies its own colormap to the whole figure. Therefore only the last subplot avoids the reset.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by