Plot histogram for multiple cases in 3 dimensions
Mostra commenti meno recenti
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?
Risposte (2)
A Lotgering
il 16 Dic 2015
Modificato: Torsten
il 13 Ago 2022
2 Commenti
Image Analyst
il 16 Dic 2015
That's actually a 2-D histogram. There are two dimensions, two independent axes. One called bins and one called "case number" - that's two. It's being displayed as a perspective plot where the third dimension a height representing the value of the histogram, but it's still a 2-D plot because there are two independent dimensions -- two indexes to the histogram array.
If you want a third dimension, you could perhaps use scatter3 where you plot markers in 3-D (again, a perspective graph) where the marker size or marker color represents the value of the histogram at that 3-D location.
Belal Essam
il 20 Nov 2021
Satyajeet Sasmal
il 15 Dic 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
Categorie
Scopri di più su Histograms in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
