Plot histogram for multiple cases in 3 dimensions
87 views (last 30 days)
Show older comments
Hi, I'm Alex and I would like to ask a question regarding the possibilities of a histogram plot.
I like to plot a "2D" histogram from a 30 by N matrix. In this 30 by N matrix data from a Monte Carlo simulation is stored for 30 different cases. The data stored in de N colums can be used for the "2D" histogram plot. However, there comes the problem. I like to plot a "2D" histogram of every case into one single '3D' plot.
If you take axis x,y,z. The plot would be something like: Horizontal x-axis is for the data stored in the N columns (Data from Monte Carlo simulation). The Vertical y-axis is for the frequency of those values to create a histogram (I call this 2D). The Horizontal z-axis is for the 30 different cases for which I like to create a similar histogram in the x- and y-axis.
The confusion is the way "2D" or "3D" histograms work. I'm not interested in a comparison histogram between the values of every case. I simply want to show every histogram into one single figure so I can show the trent between the different cases.
Thanks in advance!
Is this even possible with histograms or should we use a different plot style?
0 Comments
Answers (2)
Satyajeet Sasmal
on 15 Dec 2015
Hi Andy,
Have you tried using the "hist3" and bar3 functions? Please see the sample code below:
vec_x = [1 2 4 5 7 8 9 3 8 7 2]';
vec_y = [1 3 9 5 7 8 1 3 2 9 2]';
vec_bin_edges = 0:9;
hist3([vec_x vec_y], 'Edges', {vec_bin_edges, vec_bin_edges});
mat_joint = hist3([vec_x vec_y], 'Edges', {vec_bin_edges, vec_bin_edges});
figure
bar3(mat_joint, 1);
axis tight
Here are the documentation links for bar3 and hist3 respectively:
-Satya
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!