How to plot 3D data in 2D graph
조회 수: 112 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (1개)
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Green에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!