Plot through bottom y-limit

1 Ansicht (letzte 30 Tage)
Adr Kmy
Adr Kmy am 6 Aug. 2019
Beantwortet: Steven Lord am 6 Aug. 2019
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.

Akzeptierte Antwort

neil jerome
neil jerome am 6 Aug. 2019
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

Weitere Antworten (1)

Steven Lord
Steven Lord am 6 Aug. 2019
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')

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by