I have created a checkerboard heatmap with imagesc, using 9 subplots for an 11x11x9 array. I would like to clearly denote the 'maximum value' in each column with a red 'x' placed inside the center of each cell.
Below is the code I run to (successfully) generate the subplots. The commented section is my failed attempt to start drawing these 'x' markers – hoping for some help. Thank you!
[max_val, ~] = max(cond_npvnetrevcumlist_btfc0_417_extinct(:));maxcaxis = max_val;[min_val, ~] = min(cond_npvnetrevcumlist_btfc0_417_extinct(:));mincaxis = min_val;figurefor k=1:9 subplot(3,3,k) C=cond_npvnetrevcumlist_btfc0_417_extinct(:,:,k); I=imagesc(C); %colorbar
title(['Initial Bt Resistance Alleles=' num2str(InitResistList(k)*100) '%']) ylabel('% Bt Planted') xlabel('GM DBM release rates') ticknumx = linspace(0,12,13); ticknumy = linspace(0,11,12); set(gca,'xtick',ticknumx,'ytick',ticknumy) xticklabels({'0','0', '0.5', '1', '1.5', '2', '4', '6', '10', '15', '20', '40'}) yticklabels({'0','0','10','20','30','40','50','60','70','80','90','100'}) c=colorbar; c.Label.String = '% Max Revenue, net seed+releases'; caxis([mincaxis,maxcaxis]) %Engage to equate across all colorbar values; makes it harder to see the max within each matrix though
% %Failed attempt thus far to draw an 'x' in the centroid of the matrix cell of each column maximum value
% markers = zeros(11,1);
% for m=1:11
% [~, max_val_col] = max(cond_npvnetrevcumlist_btfc0_417_extinct(:,m,k));
% markers(m)= max_val_col;
% end
% pos=zeros(11,2);
% for n=1:11
% pos(n,1)=n;
% pos(n,2)=markers(n);
% end% color={'magenta'};
% RGB=insertMarker(I,pos,'x','color',color);
end
Best Answer