How to plot 3D data in 2D graph

조회 수: 112 (최근 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