I need to rotate my 3D figure
2 次查看(过去 30 天)
显示 更早的评论
I have particle size data for differrent De(parameter) values.
I have plotted 2Dbar graphs, I want stack all figures into one 3D figure window.
I stacked everything, that looks like the image below

But I want to rotate axis in such a way that: Particle_density(Y-axis) in vertical, Particle size(X-axis) in horizontal and De (z-axis) per pendicular to the screen. It should look like this image below

I have attached my matlab code to this thread.
Please guide me, how to do this. Thanks in advance
0 个评论
采纳的回答
Star Strider
2025-4-5
Try something like this —
% clc,clearvars,
% close all
% Example X and Y data
x = linspace(0, 50, 100); % Common X-axis for all datasets
y1 = exp(-0.1*(x-10).^2);
y2 = exp(-0.1*(x-20).^2);
y3 = exp(-0.1*(x-30).^2);
% % Plotting
figure;
hold on
patch([x flip(x)], [zeros(1,size(x,2)*2)], [zeros(size(x)) flip(y1)], 'r', EdgeColor='r', DisplayName='y_1')
patch([x flip(x)], [zeros(1,size(x,2)*2)]+0.3, [zeros(size(x)) flip(y2)], 'g', EdgeColor='g', DisplayName='y_2')
patch([x flip(x)], [zeros(1,size(x,2)*2)]+0.6, [zeros(size(x)) flip(y3)], 'b', EdgeColor='b', DisplayName='y_3')
hold off
view([-45,25])
grid on
zlim([-0.5 2.5])
xlabel('Particle size');
ylabel('Particle density');
zlabel('De');
legend(Location='best')
Here, the patch funciton will produce 3D plots if given three arguments. The first of these is the common ‘x’ row vector, the second is an spppropriate-length zeros vector with an added offset for the ‘y’ coordinate, and the ‘y#’ vectors are the ‘z’ coordinates. The patch funciton fills a closed curve, and the closures are created by using flip function to duplicate the original vectors with their orders reversed.
Make appropriate changes to get the result you want.
.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!