Why does pcolor adds a flat lines during a data gap instead of white space?

조회 수: 3 (최근 30일)
megha
megha 2024년 10월 25일
댓글: Voss 2024년 10월 25일
I use pcolor command to make a color plot. The data has a some gaps (NaN values) in it where a white space is expected.
However, I get flat horizontal lines during that period. Any help appreciated. I tried both shading flat and shading interp, it shows same. However, I do see actual white space at certain instants. I could not figure out why! I attach an example for each case below. Both occurs in the same plot.
EDITS: Data Attached
h_fig = pcolor(T_,E_log,(double(FPDO))');
% h_fig.EdgeColor = 'none';
xlim([0,T_(end,1)]); ylim([-2.5,log10(30)]);
colormap(jet); shading interp;
caxis([3,7]) % change caxis same as mar27_2017_omni_L_fesa_pile
Any help will be appreciated.

채택된 답변

Voss
Voss 2024년 10월 25일
load FPDO.mat
load E_log.mat
load T_.mat
T_ = T_lepi;
The problem is that T_ and E_log are not monotonic:
figure
subplot(2,1,1)
plot(T_,'.-')
ylabel('T\_')
subplot(2,1,2)
plot(E_log,'.-')
ylabel('E\_log')
So pcolor has to jump around and connect points across what would be the NaN gaps.
Sort the vectors and reorder the rows and columns of the matrix FPDO accordingly, pcolor with those reordered values, and you get the proper gaps where the NaNs are:
[T_sorted,Tidx] = sort(T_);
[E_log_sorted,Eidx] = sort(E_log);
FPDO_plot = FPDO(Tidx,Eidx);
figure
pcolor(T_sorted,E_log_sorted,FPDO_plot.');
axis tight
colormap(jet); shading interp;
clim([3,7])
Or reorder in the T dimension only:
[T_sorted,Tidx] = sort(T_);
FPDO_plot = FPDO(Tidx,:);
figure
pcolor(T_sorted,E_log,FPDO_plot.');
axis tight
colormap(jet); shading interp;
clim([3,7])
  댓글 수: 2
megha
megha 2024년 10월 25일
@Voss amazing job! I would have never been able to figure this out! I appreciate your time and efforts. Thanks!

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by