3d plot plotting in 2d and 2d plot plotting in 3d.
3 views (last 30 days)
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):
Eamon Gekakis on 24 Jun 2022
Remove the holds from the code, you do not need to specify hold on/off if you are plotting two separate figures
This may work better
Star Strider on 24 Jun 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);
% hold off
The zeros (constant) vector can be on any axis. I chose ‘z’ here.