MATLAB: How to shift xaxis location to origin (0,0)

axisshift

Attached is my graph that I have plotted. How to shift the x axis position so that it will be plotted on y=0? Anyway I am using R2013a version of MATLAB.
thank you

Best Answer

OK, got a minute now...
hAx=axes; % a new axes
plot(randn(10,1)) % put some data on it...
yl=ylim; % get y-axis limits
pos=get(hAx,'position'); % and axes position vector
yrat=yl(end)/(yl(end)-yl(1)); % fractional position of origin relative y range
yht=yrat*pos(4); % adjusted second axes height
pos(2)=pos(2)+pos(4)-yht; % new bottom is top position {pos(2)+pos(4)} less height
pos(4)=yht; % and new height into vector
hAx(2)=axes('position',pos,'color','none'); % second axes with this position an no color
set(hAx(2),'ytick',[]) % clear unwanted ticks from showing...
set(hAx(1),'xticklabel',[]) % clear labels on first x-axis
linkaxes(hAx,'x') % and synchronize x-axes
grid(hAx(1),'on') % just a touch
This produced
for a particular set of random data; your result will vary...