An open exchange for the MATLAB and Simulink user community |
Hosted by The MathWorks |
|
| Related Topics |
| New Products | Support | Documentation | Training | Webinars | Jobs | Newsletters |
| Problems? Suggestions? Contact us at files@mathworks.com | © 1994-2008 The MathWorks, Inc. Trademarks Privacy Policy |
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.
Doug
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.
Doug
Hi Doug,
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.
Help?
Thanks,
Daphne
Daphne,
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.
Doug
Hi Doug,
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,
Daphne
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…
Best wishes,
Marie