How can draw univariate histogram in XY plane, YZ plane, and XZ plane in a 3-dimensional space?
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Simran
2025-3-27
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:
“histogram”: https://www.mathworks.com/help/releases/R2021a/matlab/ref/matlab.graphics.chart.primitive.histogram.html
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Histograms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!