Why do XLim and YLim not work?

5 次查看(过去 30 天)
Claude
Claude 2013-8-25
Hi! I'm quite new to Matlab and want to use it to plot some data. This is my code so far
figure(1), clf
dirs = {'1M', '3M', '15M','80M'};
colour={'k','r','g','b'};
for i=1:4
cd(dirs{i});
data = load('summary.txt');
Teff = data(:,6);
L = data(:,4);
semilogy(10.^Teff, 10.^L,colour{i}), hold on
cd '..'
end
labels = sort(str2num(get(gca,'YTickLabel')));
set(gca, 'XDir','reverse','YTickLabel',labels, 'YTick', [1 10 100 1000 10000 100000 1000000 10000000], 'XGrid', 'on')
xlabel('...')
ylabel('...')
mylegend = legend('1 M','3 M','15 M','80 M');
set(mylegend, 'Location', 'SouthWest')
Now, I want to limit the x- and y-axis and I added
set(gca, 'XLimMode', 'manual', 'XLim', [0 5], ...
Unfortunately after adding this I get the right x-axis limits, but everything before this command has dissapeared from the plot.
How can I add a x- and y-axis limitation to my plot without removing everything?
Thank you very much! Claude

回答(1 个)

Walter Roberson
Walter Roberson 2013-8-25
The content of your plot would disappear if you do not have at least one line segment that starts and ends within the range you set to (0 to 5, before log)

类别

Help CenterFile Exchange 中查找有关 Legend 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by