Have you ever wanted to zoom in on one axes and have another axes zoom in at the same time? Have you ever wanted to zoom in only on the x-axis but not the y-axis? If so, please watch this minute and a half video to see how.
You can follow any comments to this entry through the RSS 2.0 feed.
You can skip to the end and leave a comment. Pinging is currently not allowed.
9 CommentsOldest to Newest
Hi,yes linkaxes(h,'xy') is useful when you want to zoom in/out subplots together.but the disadvantage is that axes being linked have to have the same xy limits,how do u zoom both if your axes don't have the same limits? i tried linkprop,but do not work.
If you want to link axes but not lock them exactly together, you can do that with the set and get commands to set the xlim and ylim properties of the axes. This is likely done with callbacks too.
How can I implement the linkaxes function within Matlab 6? Thanks
If you have an older version of MATLAB (before this function was introduced) you can get much the same effect by using SET, GET, and callbacks that will change the xlim and ylim properties of the other axes.
Not as easy, but it can be made to work. It might just be better to get the newest version of MATLAB.
I know this is a long time after the post, but am hoping you will still get to this.
I would like to link a few axes and have them zoom in togetehr, however the problem is that these axes are each plotted separately.
I have 3 axes in a GUI. Each one is a step in an image processing procedure that I am running. I would like to be able to zoom in on the 1st axes, then plot the second and have the zoom remain (same for when I add the 3dd plot). I have been able to do this for the first time, but then if I replot always returns to full size.
When you do the plot again, MATLAB may be creating a new axes that replaces the original. Some plot routines do this quietly. You need to set up the xlim, ylim, and linkaxes again when this happens. Depending on the kind of plot you are doing, it might be better to do a LINE, rather than a PLOT. This is more surgical, and changes less of the props in the axes and such.
If only life were so simple. My "plots" are actually images from a microscope, which I pre-process in the gui to determine filter parameters etc. I use imagesc to show them.
I have tried setting the xlim, ylim to the zoomed value, but didn't quite work. Will try again to find the right place to redefine.
Thanks for the input,
Dear Daphne and Doug,
I had the same problem with trying to link images. The problem arises from the fact that the handle returned from image scale is not an axis and linkaxes' error checking throws an exception. I checked the parent, and it is an axis. Linking the two parent axes gives the correct behavior:
% Link two images
% get(h, 'Parent') returns the axes associated
% with the images. I don't think this is documented
% behavior, so it is probably subject to breakage, and
% really should be moved into a supported function
% such as linkprop/linkaxes with the appropriate function.
% As get(h, 'Parent') returns a cell array, we need to
% convert it to a matrix.
linkaxes(cell2mat(get(h, 'Parent')), 'xy');
Doug, I don't know enough about when Matlab replaces axes to know whether this will survive Daphne's replot...
Very nice post. I simply stumbled upon your blog and wanted
to say that I have really enjoyed surfing around your weblog posts.
After all I will be subscribing to your feed and I'm hoping you write again very soon!