How to move a (x,y) line plot to the z axis?
Afficher commentaires plus anciens
Hi everyone
I have recently got matlab and have been trying to use it to plot some functions. So far, i have been using plot(x,[y0,y1,y2....]) to plot several functions in one 2D plot, how can i move the y lines along the z axis to give a 3d view instead of them overlapping, with spacing long z, (0:7.5:60). So y0 would be at z=0, y1 at z=7.5, y2 at z=15. If the spacing can be filled in aswell to look like a smooth plain. If that makes any sense any help would be welcome. Thank you.
1 commentaire
José-Luis
le 22 Oct 2014
I don't get it. Can't you just stack your lines in a 2D plot (add an offset to the y values)?
Réponses (1)
Matt Tearle
le 22 Oct 2014
Modifié(e) : Matt Tearle
le 22 Oct 2014
Something like this, perhaps?
x = linspace(0,1)';
y1 = cos(2*pi*x);
y2 = x.^2;
y3 = y1.*y2;
ribbon(x,[y1,y2,y3],1)
The "z" values (actually x in MATLAB's world!) are 1, 2, 3,... instead of 0, 7.5, 15,... but that can be faked, if you really need:
ax = gca;
n = (1:3)'; % change the 3 to however many y variables there are
ax.XTick = n;
ax.XTickLabel = num2str(7.5*(n-1));
Catégories
En savoir plus sur Annotations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!