필터 지우기
필터 지우기

colormap for relative 2d histogram

조회 수: 4 (최근 30일)
Rory Staunton
Rory Staunton 2011년 6월 10일
I have two 2d histograms (in the form of nxm matrices whose elements are populated with 0 or a positive real number). Call them A and B.
I want to overlay A and B to see how they differ, by subtracting so C=A-B, somewhat like in a gene expression map where upregulation is green and downregulation is red. I believe there is a nice colormap available for this already in the File Exchange.
However what I want is somewhat different. If A(25,25)=10.2 and B(25,25)=10.1, so C(25,25)=0.1. Let's also say A(2,1)=0.2 and B(2,1)=0.1, so that C(2,1)=0.1.
I don't want C(25,25) to end up the same color as C(2,1) because I would be losing the information that in both histograms (25,25) is well-populated and (2,1) is not.
One (somewhat still dissatisfactory) solution would be to map the green/red hue of each cell to the sign of the difference A-B so anything positive is green and anything negative is red; and to map the grayscale intensity of the cell to the sum A+B, with white being A+B=0 and black corresponding to some high value.
Does anyone know how to go about doing something like this? It should be simple for someone who knows, but it seems impossible for someone (me) who doesn't! Thanks!

채택된 답변

Walter Roberson
Walter Roberson 2011년 6월 10일
How about if you plotted the two histograms on the same axis, with different translucent colors? The place where they were the same would be dark because it would have both colors, the one that was greater would extend further up in its own color.
thick = 0.75; %alpha
bh1 = bar(histogram1);
hold on
bh2 = bar(histogram2);
patches = findobj([bh1, bh2],'-property','AlphaData')
for ph = patches
set(ph,'AlphaData', thick * get(ph,'AlphaData'));
end
  댓글 수: 3
Rory Staunton
Rory Staunton 2011년 6월 10일
(they're 2d histograms) I guess hist3 might work but I have neevr used it...
Walter Roberson
Walter Roberson 2011년 6월 10일
There is bar3(). The code I gave should work for bar3() as well.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by