Plot a time series plot in customized rectangle

조회 수: 3 (최근 30일)
Sujata Dhar
Sujata Dhar 2024년 4월 2일
댓글: Sujata Dhar 2024년 4월 2일
I am plotting a time series from the attached data.
plot(time,pm_1,'b-','LineWidth',3);
I am getting the following plot (plot_xp.png). But I want my plot to be in a rectangle window like the attached (desired_plot.png). Can you please help me with the necessary changes.
Thank you very much
  댓글 수: 1
Nathan Bblanc
Nathan Bblanc 2024년 4월 2일
편집: Nathan Bblanc 2024년 4월 2일
I think if you just write:
plot(time,pm_1);
grid off
and change the size of the figure window a bit, you will get what you want. You can also play around with hte colors and linewidths. for example
plot(time,pm_1,'r-','LineWidth',1);
will give you a red line with a line width of 1

댓글을 달려면 로그인하십시오.

채택된 답변

Adam Danz
Adam Danz 2024년 4월 2일
Previous answers suggest changing the size of the figure window which is one solution.
Another solution is to set the size of the axes or the PlotBoxAspectRatio.
Take this sine curve for example.
th = 0:.1:120;
figure()
plot(sin(th))
Next, define the aspect ratio of the axes such that the x axis is 5 times longer than the y axis. I'll ignore the z axis since this is a 2D plot.
figure()
ax = gca;
plot(sin(th))
ax.PlotBoxAspectRatio(1:2) = [5,1]; % 5:1 x:y

추가 답변 (2개)

KSSV
KSSV 2024년 4월 2일
편집: KSSV 2024년 4월 2일
plot(time,pm_1,'b','LineWidth',1); % You may change line width

Nathan Bblanc
Nathan Bblanc 2024년 4월 2일
편집: Nathan Bblanc 2024년 4월 2일
nathan blanc about 2 hours ago
Edited: nathan blanc about 2 hours ago
plot(time,pm_1);
grid off
and change the size of the figure window a bit, you will get what you want. You can also play around with hte colors and linewidths. for example
plot(time,pm_1,'r-','LineWidth',1);
will give you a red line with a line width of 1

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by