Why do XLim and YLim not work?
5 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Walter Roberson
on 25 Aug 2013
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)
0 Comments
See Also
Categories
Find more on Legend in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!