Data disappears from plot when setting axes limits?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Joshua Stephen
am 9 Jun. 2018
Kommentiert: Joshua Stephen
am 9 Jun. 2018
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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 9 Jun. 2018
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)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Graphics Performance finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!