Handling axes as arguments
11 views (last 30 days)
Show older comments
Ria3242 on 4 May 2016
Commented: Mike Garrity on 4 May 2016
In my GUI, there are 5 axes, one displays a grid of images, and the others display the cropped images from the grid having one cropped image from mouse input to be displayed on one axis in a sequence i.e. an image password of having four sub-images will be formed further. At first I was setting the new axis for the next cropped image by handling it in a loop. There were warnings regarding speed. Then I passed the handles in arguments as:
a2 = axes(handles.axes2);
a3 = axes(handles.axes3);
a4 = axes(handles.axes4);
before my loop started. and within the loop I ploted where I wanted:
now it gives me these errors:
Error using axes Too many output arguments.
Error in a2 = axes(handles.axes2);
Thanks in advance!
Axes only returns an axes handle in the cases where it is creating an axes object. The syntax where you pass an axes handle in is different. In that case, it's not creating an axes, it's just setting gca. It sounds like you probably want something like this instead.
a2 = handles.axes;
Alternatively, you could skip the call to axes entirely. It looks like you're going to pass the axes handle into your plotting function. Therefore you really don't need to make it gca. But making it gca does have the nice side effect of making sure that the figure is in front of other windows.
I'm afraid I don't know the history of that one. I'm afraid that it goes way, way back.
We have been on a bit of a kick of making things more uniform lately. Perhaps this one should be on the todo list.
Find more on Specifying Target for Graphics Output in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!