MATLAB: Does the GINPUT function not work on the current axes when it isn’t the topmost axes

frontMATLAB

I use the following code to create two axes; axes 'b' lies on top of axes 'a':
f=figure;
a=axes;
pcolor([1:4;1:4;1:4;1:4]);
hold on
b=axes;
plot(1:10,'k');
set(b,'color','none');
I then set the axes 'a' as the current axes without bringing it to the front of axes 'b', and use the GINPUT command as follows:
set(f,'currentaxes',a)
ginput(1)
The x and y coordinates obtained are from axes 'b' instead of axes 'a'.

Best Answer

This is an error in the MATLAB function reference documentation for the GINPUT function. The documentation should read as follows:
[x,y] = ginput(n) enables you to select n points from the current axes and returns the x-and y-coordinates in the column vectors x and y, respectively. When there are multiple axes that overlap, GINPUT selects points from the axes on top.