3d plot plotting in 2d and 2d plot plotting in 3d.
50 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I am plotting both a 3d plot and 2d plot, using "plot3" to plot the 3d plot and "plot" to plot the 2d plot. When I do either or seperately, they plot fine. However, trying to plot them together in the same code results in the 3d plot being plotted in 2d, and the 2d plot being plotted in 3d.
The code is long, but the plotting sections are basically this (where x y z is one set of data, and a b is a different set of data):
figure(1)
hold on
plot3(x,y,z)
hold off
figure(2)
hold on
plot(a,b)
hold off
0 comentarios
Respuestas (2)
Eamon Gekakis
el 24 de Jun. de 2022
Remove the holds from the code, you do not need to specify hold on/off if you are plotting two separate figures
figure(1)
plot3(x,y,z)
figure(2)
plot(a,b)
This may work better
0 comentarios
Star Strider
el 24 de Jun. de 2022
The must both plot in 3D, however the ‘z’ value of the 2D plot can be whatever you want (here, 10) —
x = 0:0.5:5;
y = 0:0.2:2;
z = x.^2 + y.^2;
a = x;
b = sqrt(x);
figure(1)
hold on
plot3(x,y,z, '-b')
% hold off
% figure(2)
hold on
plot3(a,b,zeros(size(a))+10,'-r')
hold off
view(30,30)
grid on
xlabel('(x),(a)')
ylabel('(y),(b)')
zlabel('z')
The zeros (constant) vector can be on any axis. I chose ‘z’ here.
.
0 comentarios
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!