Reputation: 335
xlim command changes the axis limit of the figure. How can i also limit data that is contained by the figure? Apparently, even though xlim is applied data is still there.
Example: let's say i have a data set of 5000 elements. but only 1500 elements are shown in a figure. when i save this figure, it will still contain data that is not shown in the figure.
The answer may be particularly useful for people working with matlab2tikz.
Upvotes: 1
Views: 741
Reputation: 112749
Yes, the data are still there. To remove data, use something like this:
>> plot(1:10,(1:10).^2); % just an example
>> h = get(gca,'Children');
>> x = get(h,'XData')
x =
1 2 3 4 5 6 7 8 9 10
>> y = get(h,'YData')
y =
1 4 9 16 25 36 49 64 81 100
>> set(h,'XData',x(2:5), 'YData',y(2:5))
>> set(h,'XData',x(2:5), 'YData',y(2:5))
Upvotes: 1