Data disappears from plot when setting axes limits?
6 ビュー (過去 30 日間)
古いコメントを表示
I'm trying to display a figure with three plots on it. The data in the third is of lower amplitude than the first two plots, and as such Matlab defaults to setting a smaller scale. I want to be able to set the axes limits on all three, however when I do the plots return with no data in them. I've tried moving the axes limits to what it would set them to by default and the problem still persists
My code is as follows,
figure
ax1 = subplot(3,1,1);
plot(IN1);
xlim([0 0.3]);
ylim([-0.01 0.01]);
xlabel('Time');
ylabel('Amplitude');
ax2 = subplot(3,1,2);
plot(IN2);
xlim([0 0.3]);
ylim([-0.01 0.01]);
xlabel('Time');
ylabel('Amplitude');
ax3 = subplot(3,1,3);
plot(IN3);
xlim([0 0.3]);
ylim([-0.01 0.01]);
xlabel('Time');
ylabel('Amplitude');
If I comment out the xlim & ylim functions it works fine. (See pictures below) I'm running R2015B on an Imac running macOS10.15
Any help would be greatly appreciated!


0 件のコメント
採用された回答
Walter Roberson
2018 年 6 月 9 日
You have no data in the first 0.3 seconds.
You are plotting without an explicit x axis, so it is going to assume that the x axis is 1 to the length of your data, which is about 10^5 samples. Your first sample time is therefore 1. You have nothing between 0 and 0.3.
You might need something like
plot(t, IN1)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!