Azzera filtri
Azzera filtri

colormap for relative 2d histogram

4 visualizzazioni (ultimi 30 giorni)
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!

Risposta accettata

Walter Roberson
Walter Roberson il 10 Giu 2011
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 Commenti
Rory Staunton
Rory Staunton il 10 Giu 2011
(they're 2d histograms) I guess hist3 might work but I have neevr used it...
Walter Roberson
Walter Roberson il 10 Giu 2011
There is bar3(). The code I gave should work for bar3() as well.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Data Distribution Plots in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by