How can draw univariate histogram in XY plane, YZ plane, and XZ plane in a 3-dimensional space?

4 views (last 30 days)
I have N samples in four categories whose 3D coordinates are given. I want to plot univariate histograms for the X on XY plane at Z=0 of a 3D box. Next, on the adjacent walls of this box, I have to plot univariate histograms for Y on YZ plane at X=0 and univariate histogram for Z on XZ plane at Y=0.
I have attached data with categories.
I am new in matlab. Please help me.
  2 Comments
sharmin sathi
sharmin sathi on 15 Dec 2021
Edited: sharmin sathi on 15 Dec 2021
I have attached an image that i want. This image is for one category data and present histogram Y axis and Z axis. But i want to represent histogram X axis, Y axis and Z axis for the four cateories data attached previously.
thanks in advance

Sign in to comment.

Answers (1)

Simran
Simran on 27 Mar 2025
To visualise your data in a 3D box specifically by plotting histograms on the walls of the box, you can follow the following steps:
1.) Import your data file into MATLAB using the “readtable” function.
2.) Extract the X, Y, Z coordinates from the table.
3.) Then create a new figure.
4.) Plot histogram for X on the XY plane at Z=0, Y on the YZ plane at X = 0, Z on the XZ plane at Y = 0 as follows:
subplot(2, 2, 1);
histogram(X);
title('Histogram of X (XY plane at Z=0)');
xlabel('X');
ylabel('Frequency');
view(2);
subplot(2, 2, 2);
histogram(Y);
title('Histogram of Y (YZ plane at X=0)');
xlabel('Y');
ylabel('Frequency');
view(2);
subplot(2, 2, 3);
histogram(Z);
title('Histogram of Z (XZ plane at Y=0)');
xlabel('Z');
ylabel('Frequency');
view(2);
After following the above steps and adjusting the layout, this is the figure I got:
For more help, you can refer to the following documentation:

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!