How to plot 3D data in 2D graph

134 visualizzazioni (ultimi 30 giorni)
Lukas Cierny
Lukas Cierny il 18 Nov 2020
Commentato: Lukas Cierny il 19 Nov 2020
Hello all,
I need help how to plot 3D data on 2D graph. I have data measured in time for example from t = 0s to t = 60s for each time is certain value of electric current (x-axis) versus some quantity (y-axis). I need to plot y versus electric current (x-axis), but still with respect to time.
Thank you very much for a hint in advance.

Risposte (1)

Cris LaPierre
Cris LaPierre il 18 Nov 2020
You could create a 3D plot, and then rotate it so you are just looking at the XY plane. You can do this using view(2). You could try to use color to represent the value of your 3rd variable.
What works is going to be very dependent on your data. You might consider the answer provided here if your plot is a line.
% 3D
t = linspace(0,10,500);
xt = exp(-t./10).*sin(5*t);
yt = exp(-t./10).*cos(5*t);
patch([xt NaN],[yt NaN],[t NaN],[t NaN],'FaceColor','none','EdgeColor','interp');
xlabel("X")
ylabel("Y")
zlabel("Time")
cb=colorbar;
cb.Title.String = "Time";
colormap jet
view(3)
%2D
figure
patch([xt NaN],[yt NaN],[t NaN],'FaceColor','none','EdgeColor','interp');
xlabel("X")
ylabel("Y")
cb=colorbar;
cb.Title.String = "Time";
colormap jet
  1 Commento
Lukas Cierny
Lukas Cierny il 19 Nov 2020
Hello, thank you very much for so quick response. I will try it, but seems to be good procedure.

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by