Why does pcolor adds a flat lines during a data gap instead of white space?
33 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
megha
am 25 Okt. 2024 um 18:54
Kommentiert: Skye
am 28 Okt. 2024 um 11:58
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.
1 Kommentar
Skye
am 28 Okt. 2024 um 11:58
I faced a similar issue while working with pcolor for my assignment, where NaN values caused unexpected flat lines in the plot. One approach that helped me was ensuring the CData matrix was structured properly for MATLAB to interpret NaN as gaps. Additionally, I found that experimenting with different plotting functions, like imagesc, can sometimes handle NaN values better without those flat lines. If you’re looking for extra help, I highly recommend www.matlabassignmentexperts.com. They provided excellent guidance for my MATLAB project, and their support team is super responsive. You can reach them on WhatsApp at +1 (315) 557-6473 or email them at info@matlabassignmentexperts.com.
Akzeptierte Antwort
Voss
am 25 Okt. 2024 um 19:47
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!