2D Histograms in Planes XZ, YZ

조회 수: 4 (최근 30일)
Manuel
Manuel 2014년 2월 6일
답변: Manuel 2014년 2월 7일
Hello, I am trying to get a representation similar to the one attached to this message. That is to say, I would like to represent two 2D-histogram, one in the plane XZ and the other in the plane YZ. In X and Y, the magnitude to be displayed is the same, but the thing is that the Z-axis is different. As I want to make the representation clearer, I would add additional information in the plane Z=0, that is the reason for which I have not used the 2D-histogram with two different Y-axes. It would be very nice if you could help me to solve this. Thanks in advance, Manuel.

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2014년 2월 6일
OK, here's a simple example where you plot a few pieces together...
% First some "test-data":
x = randn(500,1);
x = x-min(x)+0.5;
y = randn(500,1);
y = y-min(y)+0.5;
y = y.^1.5+1*x;
z = exp(-abs(2*x-y)/4); % Just to get something similar to the figure linked to in your reference
[Nx,xH] = hist(x,9); % Histogram of X-values
[Ny,yH] = hist(y,11); % and Y
dX = gradient(xH); % Spacing between histogram bin centres
dY = gradient(yH);
%%Plot stuff...
scatter3(x,y,z,15,z,'filled') % The points
for i1 = 1:length(xH), % And the X-histogram bars
pHmyX(i1) = patch(xH(i1)+dX(i1)*[-1 1 1 -1 -1]/2,...
[0 0 0 0 0],...
[0 0 Nx(i1)*[1 1] 0],rand(1,3));
end
for i1 = 1:length(yH),
pHmyY(i1) = patch([0 0 0 0 0],...
yH(i1)+dY(i1)*0.9*[-1 1 1 -1 -1]/2,...
[0 0 Ny(i1)*[1 1] 0],rand(1,3));
end
You should be able to modify and extend that to suit your needs.
HTH

추가 답변 (4개)

Manuel
Manuel 2014년 2월 6일
Sorry. The plot appears in this link:

Bjorn Gustavsson
Bjorn Gustavsson 2014년 2월 6일
Well, have you tried what Walter suggested in his reply in the thread you linked to? Should work, then with the 2 histograms in the XZ and YZ planes you can continue to plot whatever you wanted...
HTH
  댓글 수: 1
Manuel
Manuel 2014년 2월 6일
Thank you for your answer, Bjorn. Yes, I have tried to do what Walter proposed, but I am quite new in Matlab and I am having some problems facing this. I think that any simple code as example would help me a lot to see what Walter suggests in his answer.

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


Manuel
Manuel 2014년 2월 7일
Thank you very much, Bjorn.

Manuel
Manuel 2014년 2월 7일
As an alternative to what Bjorn has proposed, I would like to say that I got something similar to this using the command "fill3(X,Y,Z,COLOR)" and defining previously in X, Y and Z the coordinates of the bars (so, if I want to project the histogram in the plane XZ, the only thing I have to do is defining always Y=0). In my case, I projected two histograms using this "fill3" function, and then I plotted a 3-D bar graph with the colormap using "bar3color" (instead of a scatter plot, as in the previous example). Regards.

카테고리

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