Reputation: 89
I have a graph with a lot of points and I want to be able to look at certain intervals using xlim
. The issue is, when I increment the interval, I have to rerun my program. This is taking a lot of processing power.
So basically, I make graph using plot
, then use xlim
. I don't want to keep doing this. Is there a way to plot only certain intervals using plot
? That way, MATLAB doesn't have to process the whole vector.
For example
A=[1,2,3,4]
and
B=[1,2,3,4]
If I do plot(A,B)
then xlim(1,2)
it would plot the graph first and then limit the interval. This takes a lot of processing power if you imagine a really massive complicated graph, thus I don't want to use plot using the normal method.
Is there a way to plot the graph on the interval x=[1,2]
with only one function?
Upvotes: 0
Views: 88
Reputation: 311
Update the XLimMode
and NextPlot
properties of your axes object before plotting. e.g.
x = randn(128,1);
y = randn(128,1);
hax = axes();
hax.XLimMode = 'manual';
hax.XLim = [1,2];
hax.NextPlot = 'add';
h = plot(x,y,'o','Parent',hax)
hax.NextPlot = 'replace'; % optional
Upvotes: 1