2 x 2d histograms from hist3

1 次查看(过去 30 天)
Tim Fulcher
Tim Fulcher 2020-12-9
Hi all,
I'm plotting a 3d histogram centered about x = 0 and y = 0. Is it possible to extract 2 x 2d histograms along the x and y axes from that 3d histogram?
Thanks and regards
Tim
  3 个评论
Tim Fulcher
Tim Fulcher 2020-12-9
Two 2d histos. In this case one on the x axis and the other on the y axis.
Adam Danz
Adam Danz 2020-12-9
Could you find an image or drawing that looks like what you're trying to achieve?
Are you describing an axis with vertical and horizontal histograms, potentially overlapping, and if so, what happens with the 3rd dimension (the height of the 3D bars)?
Or are you describing a 3D histogram that is flattened to 2D where color depicts the height of the bars?

请先登录,再进行评论。

回答(1 个)

Steven Lord
Steven Lord 2020-12-9
Let's say you had this 2-dimensional histogram.
xy = [1 1; 1 1; 1 1; 1 -1; 1 -1; -1 1; -1 1; -1 -1];
histogram2(xy(:, 1), xy(:, 2), 'XBinEdges', -1.5:1.5, 'YBinEdges', -1.5:1.5)
Would you want the 1-D histogram for y to look like this (note the horizontal lines, where the shorter bars in front end but the taller bars behind continue up?)
histogram2(xy(:, 1), xy(:, 2), 'XBinEdges', -1.5:1.5, 'YBinEdges', -1.5:1.5);
view([-1 0 0])
or this? Note that in this histogram, the order of the axes is the reverse of the order of the axes in the previous. You can set the YDir property of the axes to make the axes go from 1.5 down to -1.5 but the Answers code evaluation takes a "picture" of the figure prior to that command when I tried so I removed the command.
histogram(xy(:, 2), 'BinEdges', -1.5:1.5);

类别

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