How to plot 3D data in 2D graph

108 次查看(过去 30 天)
Lukas Cierny
Lukas Cierny 2020-11-18
评论: Lukas Cierny 2020-11-19
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.

回答(1 个)

Cris LaPierre
Cris LaPierre 2020-11-18
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 个评论
Lukas Cierny
Lukas Cierny 2020-11-19
Hello, thank you very much for so quick response. I will try it, but seems to be good procedure.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Green 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by