How to brush data of subplots containing histogram and scatterplot?

조회 수: 3 (최근 30일)
Raptrick
Raptrick 2014년 3월 12일
댓글: Raptrick 2014년 3월 14일
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

답변 (1개)

Raptrick
Raptrick 2014년 3월 13일
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
Star Strider
Star Strider 2014년 3월 13일
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 2014년 3월 14일
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

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

카테고리

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