How to set y-axes intercept
10 visualizzazioni (ultimi 30 giorni)
How do you make the y-axis cross the x-axsis at observation 1 and not 0? Sometimes it happends automatically, sometimes not. Try the code below. The two figures has different axes intercept.
A = rand(15,1);
How do you make the y-axex always intercepting at x=1, as in figure 1 above?
Jonathan LeSage il 24 Ott 2013
You can set the limits of the x-axis directly using the xlim function. If you're plotting (x,y) data, you can easily just set the lower x-limit equivalent to your first data point. Here is a little example to help get you started:
% Generate arbitrary data and plot
numPoints = 15;
x = 1:numPoints;
A = rand(numPoints,1);
% Get current x-limits
currentLimits = xlim;
% Set x-limits to ensure graph starts at first data point
As you can see, the xlim function can be used to both get information on the current axes and to set limits. Hope this helps!