How I can zoom two axes of different scale by the same relative amount at the same time using the ZOOM tool in MATLAB 7.8 (R2008b)?
1 view (last 30 days)
Show older comments
I have two overlapping axes on the same figure. They are each at separate scales. I would like to zoom both axes by the same relative factor.
Accepted Answer
MathWorks Support Team
on 15 May 2015
To do this with numeric axes, you will need to create a ZOOM object and set its ActionPostCallback method to a callback function that manually coordinates the two different axes limits.
As an example, see the attached file, CreateFigure.m, which includes code to perform this. To test it, try zooming into a section of the code and confirm that both axes zoom as expected.
The callback that was defined in this function is as follows:
function myzoom(obj,event_obj)
% obj handle to the figure that has been clicked on
% event_obj object containing struct of event data (same as the
% event data of the 'ActionPreCallback' callback)
ax = findobj(obj.figure, 'type','axes');
axes1 = ax(1); axes2 = ax(2);
axisvals = [get(axes1,'xlim'),get(axes1,'ylim')];
% Focus on bottom axes
set(axes2,'xlim',[pi/180*axisvals(1:2)]);
set(axes2,'ylim',axisvals(3:4));
0 Comments
More Answers (0)
See Also
Categories
Find more on Visual Exploration 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!