Plot through bottom y-limit

조회 수: 1 (최근 30일)
Adr Kmy
Adr Kmy 2019년 8월 6일
답변: Steven Lord 2019년 8월 6일
How can I let a plot go through the bottm y-lim and connect to the next point at the oppisite (max) y-lim?
I have a x y matrix which y sapns from -180 to 180. Yet most of the data fluctuate around -180 and should then come back from the top of the plot rather than being connected going through 0.
Thanks.

채택된 답변

neil jerome
neil jerome 2019년 8월 6일
not totally obvious what you mean. if you want to avoid the automatic joining of points through the x-axis that you want to sshow as 'wrapping' around over the axes limits (i assume the ±180 is a rotational thing), you can just plot another matched series one rotation 'higher', and fixing the y-limits will give the illusion of them being a single series.
% data that crosses -180
dat = [-163 -162 -172 -168 -186 -194 -169 -163 -144 -177 -168 -171 -189 -174 -168];
DAT = dat+360; % additional rotation data
figure;
plot(1:15, dat, 'ro-'); % actual data will be clipped in figure < -180
hold on;
plot(1:15, DAT, 'bo-'); % colour just to show different series
ylim([-180 180]);
Screenshot 2019-08-06 at 17.47.10.png

추가 답변 (1개)

Steven Lord
Steven Lord 2019년 8월 6일
If you want to make a "break" in your plot, include NaN in the X and/or Y vectors.
x = 0:0.25:10;
y = x.^2;
subplot(2, 1, 1)
plot(x, y)
title('No NaN values')
subplot(2, 1, 2)
y2 = y;
y2(mod(x, 1) == 0) = NaN;
plot(x, y2);
title('NaN values in y data for integer values of x')

카테고리

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

태그

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by