# How to brush data of subplots containing histogram and scatterplot?

5 views (last 30 days)
Raptrick on 12 Mar 2014
Commented: Raptrick on 14 Mar 2014
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?)')
brush on
hS2=subplot(2,1,2);
plot(y(:,1),y(:,2),'.');
brush on Who can help me with rewriting the code using a BARH so I have a rotated histogram with a logaritmic occurence scale?

Raptrick on 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'); 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 CommentsShowHide 1 older comment
Raptrick on 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');
brush on
hS4=subplot(2,1,2);
plot(b,a,'.');
ylabel('a'); xlabel('b');
brush on This is not want I want. I need a BARH. Anyone a clue?
Patrick