Contour not working: The delineation erases (or minimizes) previous data from a plot
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Contour function issue (I think)
Hi everyone, I am trying to get a delaniation (by using contour function) on a certain area in a figure.
Long story short I have the range on neural activity in the auditory cortex (several recordings and animals)
I am trying to find the areas with most change by using 90-95% percentile and making a X-score mask at p= 0.05.
When imaging the Range: It works flawlessly.
When imaging the Zscore: It works flawlessly.
When adding the contour of the zscore to the Range it does not work and the range seems to empty:

I get no warning and no error messages...
Here is the plotting code:
nRecs3 = numel(Recordings3);
figure;
sgtitle('Mouse 168: Range per condition','fontweight','bold','fontsize',16); %overall title
for iR3 = 1:nRecs3
sp = subplot(1, nRecs3, iR3);
im = imagesc(sp, squeeze(RANGE_3(:,:,iR3)'));
hold on; colorbar;
set(gca,'DataAspectRatio',[1,1,1]);
cont = contour(sp, ZMASK_3(:,:,iR2)', 1, 'r');
title(RecordingNames3{iR3})
xlabel('Anteroposterior (mm)'); %x axis label
ylabel('Mediolateral (mm)'); %y axis label
end
Does anyone know what the issue may be and how can I fix it?
As some extra info I do the same as previously (except looking at bottom percentile) mentioned with the RATIO and that seems to work just fine:

0 Kommentare
Akzeptierte Antwort
DGM
am 24 Jun. 2023
Both the image object created by imagesc() and the contour object created by contour() rely upon the current axes colormap and caxis settings. As such, a contour plotted over an pseudocolored image will be invisible since both objects use the same scaled mapping.
You can fix this either by creating a duplicate overlaid axes:
... or by converting the pseudocolor image generated by imagesc() to an RGB image:
... or you can try to directly edit the undocumented properties of the contour() object to break its dependence on the axes colormap.
[X Y Z] = peaks(100);
imagesc(Z); hold on
[~,hc] = contour(Z,[-1 0 1]);
drawnow
levelcolors = [1 0 0; 0 1 0; 0 0 1]; % colors for each level
for k = 1:numel(hc.EdgeLoopPrims)
hc.EdgeLoopPrims(k).ColorData = im2uint8([levelcolors(k,:) 1].');
end
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Contour Plots 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!
