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 Center および File ExchangeLine Plots についてさらに検索

タグ

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by