From: Nathan on 7 Jan 2010 00:57 On Jan 6, 5:58 pm, "Nathan " <natelewis*remove.th...(a)yahoo.com> wrote: > Nathan <ngrec...(a)gmail.com> wrote in message <6600ca5c-007e-4b3f-a935-81df641a3...(a)a15g2000yqm.googlegroups.com>... > > On Jan 6, 4:51 pm, "Nathan " <natelewis*remove.th...(a)yahoo.com> wrote: > > > I regularly use imagesc to visualize a matrix. However, I was wondering if there is any utility that would allow one to split each cell into upper and lower triangles so that one could overlay two matricies (the first plotted in the upper triangle, the second plotted in the lower triangle. > > > Do you mean something like this? > > A = ones(10) > > B = ones(10)*2 > > Au = triu(A) > > Bl = tril(B) > > imagesc(Au+Bl-Au.*Bl,[0 2]) > > > Or did I not understand you correctly? > > > -Nathan > > no... more like this, but with color > > genome.cshlp.org/content/16/5/627/F4.large.jpg So, do what Image Analyst told you. Example: A = ones(10); B = ones(10)*2; C = [... 0 0 0 0 1 0 0 0 1 1 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1]; A2 = resizem(A,5,5); B2 = resizem(B,5,5); C2 = repmat(C,length(A)); D2 = A2.*~C2+B2.*C2; imagesc(D2,[1 2]) -Nathan
From: Nathan on 7 Jan 2010 12:41 I coded it up myself... function figure1 =imagesc_2mat(Matrix1,Matrix2,colormapchoice) if nargin ==0 Matrix1= rand(10,10)*2+5; Matrix2= rand(10,10)/rand(1)-randn(1); end if nargin<3 colormapchoice = redgreencmap(256,'Interpolation','linear'); end if size(Matrix1)~=size(Matrix2) error('Matricies not the same size!') end cmap2useInd = linspace(min(min([Matrix1;Matrix2])),max(max([Matrix1;Matrix2])),length(colormapchoice(:,1))); cmap2use=(colormapchoice); figure1 = figure; axes1 = axes('Parent',figure1,'YDir','reverse','Layer','top','Linewidth',2); hold on;box('on') [m n]=size(Matrix1); for i=1:m for j=1:n p = fill([j-.5 j-.5 j+.5],[i+.5 i-.5 i-.5],cmap2use(find(cmap2useInd>=Matrix1(i,j),1,'first'),:)); set(p,'Linewidth',2) p = fill([j-.5 j+.5 j+.5],[i+.5 i+.5 i-.5],cmap2use(find(cmap2useInd>=Matrix2(i,j),1,'first'),:)); set(p,'Linewidth',2) end end set(axes1,'ytick',[1:m],'yticklabel',[1:m],'xtick',[1:n],'xticklabel',[1:n],'xlim',[.5 n+.5],'ylim',[.5 m+.5]); colormap(cmap2use); colorbar('ytick',[0:.1:1],'yticklabel',linspace(min(min([Matrix1;Matrix2])),max(max([Matrix1;Matrix2])),11),'Linewidth',2);
First
|
Prev
|
Pages: 1 2 Prev: Graphical Comparison - How to approach? Next: handle of "imagesc" to make invisible |