![Screenshot 2019-08-06 at 17.47.10.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/232970/Screenshot%202019-08-06%20at%2017.47.10.png)
Plot through bottom y-limit
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
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](https://www.mathworks.com/matlabcentral/answers/uploaded_files/232970/Screenshot%202019-08-06%20at%2017.47.10.png)
0 个评论
更多回答(1 个)
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')
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!