How to brush data of subplots containing histogram and scatterplot?

6 visualizzazioni (ultimi 30 giorni)
Dear all,
From experimental data I need to find cross relations. This I will do by making a scatterplot and a histogram. I cooked some code (hereunder) but I'm not happy with result. I need the histogram generated by BARH (HGGROUP) rather than HIST (PATCH) because I want the bins on the yaxis. Also I want to have a log scale for the histogram's occurences so I need set the Baseline property to 1 instead of 0. For the sake of convenience I want link the Yaxes of both plots. Last but not least all properties have to be set programmatically not manualy.
x = -4:0.3:4;
y = randn(1000,2);
figure
hS1=subplot(2,1,1);
hist(y(:,2),x);
title('you can only manually assign y(:,2) to ydatasource (hist-->patch?)')
hl=linkdata('on');
brush on
hS2=subplot(2,1,2);
plot(y(:,1),y(:,2),'.');
linkdata on
brush on
linkaxes([hS1 hS2],'x')
Who can help me with rewriting the code using a BARH so I have a rotated histogram with a logaritmic occurence scale?
Thanks in advanced Patrick

Risposte (1)

Raptrick
Raptrick il 13 Mar 2014
Thanks for giving me an answer. Let me rephrase the question. I recooked the code and arrange the subplots as I want. Upper subplot contains rotated histogram with log occurences. Lower subplot contains scatter plot. Yaxes of subplots are linked. Why doesn't work the data brushing?
a = randn(1000,1);
b = 200*randn(1000,1)+1400;
bins = linspace(min(b),max(b),10);
[occur,binsout] = hist(b,bins);
figure
hS1 = subplot(2,1,1);
hB = barh(binsout,occur,'YDataSource','occur');
set(hB,'basevalue',1); %avoids errors when swiching to logscale
set(hS1,'xscale','log');
ylabel('b binned'); xlabel('log occurrence b');
hS2=subplot(2,1,2);
plot(a,b,'.')
ylabel('b'); xlabel('a');
linkdata on
linkprop([hS1 hS2],'ylim');
I'm not shure what to put as datasource for the histogram. Is it the variable OCCUR or is it required to recalculate it by HIST(B,BINS). How can get the same functionality as the initial question but in the layout (see picture) as I want.
Patrick
  2 Commenti
Star Strider
Star Strider il 13 Mar 2014
I am not sure what you are doing. One problem might be that variable a has zero occurrences in the bins defined by variable b in this example. It will not show up on the bar plot.
Raptrick
Raptrick il 14 Mar 2014
If I use HIST it works however with BARH it doesn't???
figure
hS3=subplot(2,1,1);
hist(b,bins);
xlabel('b binned'); ylabel('lin occurrence b');
hl=linkdata('on');
brush on
hS4=subplot(2,1,2);
plot(b,a,'.');
ylabel('a'); xlabel('b');
linkdata on
brush on
linkaxes([hS3 hS4],'x')
This is not want I want. I need a BARH. Anyone a clue?
Patrick

Accedi per commentare.

Categorie

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

Community Treasure Hunt

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

Start Hunting!

Translated by