File Exchange Pick of the Week

Our best user submissions


Bob's pick this week is linkzoom by Carlos Adrian Vargas Aguilera.

The following plot shows temperature versus depth in two sets of units.

Z = linspace(0,150)';           % Depth in meters
TC = -tanh((Z-30)/20)+23;       % Temperature in °C
dc2df = @(dc) (9/5)*dc + 32;    % °C->°F
mt2ft = @(mt) mt/0.3048;        % meters->feet

ax(1) = axes('YDir','reverse',...
             'position',[0.13 0.11 0.77 0.78]);
axis tight
xlabel('Temperature, °C')
ylabel('Depth, m')
ax(2) = axes('Position',get(ax(1),'position'),...
xlabel(ax(2),'Temperature, °F')
ylabel(ax(2),'Depth, ft')

The different units of measure are handled using a second axes. If you want to zoom and pan the plot, by default the two axes would not stay synchronized. MATLAB offers a very useful linkaxes command. That works great when plots share common X and/or Y coordinate values. In this case linkaxes would do the wrong thing. So Carlos created linkzoom. Once turned on, you can pan and zoom and both measurement scales stay in lock step. Download the submission and run this code in MATLAB to see for yourself.

Published with MATLAB® 7.9

  • print


要发表评论,请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。