2 x 2d histograms from hist3
1 view (last 30 days)
Show older comments
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 Comments
Adam Danz
on 9 Dec 2020
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?
Answers (1)
Steven Lord
on 9 Dec 2020
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);
0 Comments
See Also
Categories
Find more on Histograms in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!